Code Monkey home page Code Monkey logo

lnzcollectionlayouts's Introduction

HBC Digital
Gilt Tech

CollectionLayouts

What makes our products unique is the effort that we put in our apps for customizations.

This repository contains a collection of UICollectionViewLayout subclasses that allow customized behaviors for our UICollectionView.

Included in this repository there are 3 layouts currently used in the Saks 5th Avenue app:

  • LNZSnapToCenterCollectionViewLayout
  • LNZInfiniteCollectionViewLayout
  • LNZCarouselCollectionViewLayout

All the layouts are customizable through interface builder. It is possible to get notified through delegate pattern for updates of their elements in focus, where as element in focus is intended to be the element currently centered.

LNZSnapToCenterCollectionViewLayout

LNZSnapToCenterCollectionViewLayout

This layout is a simple horizontal layout that snaps elements to center. The first item is centered by default leaving white space on the left. This behavior is switched off by setting the var centerFirstItem to false.

LNZInfiniteCollectionViewLayout

LNZInfiniteCollectionViewLayout

This layout is an LNZSnapToCenterCollectionViewLayout that reorganize attributes while scrolling so that they are scrollable horizontally indefinitely. Each cell maintains their indexPath, and the data source order is not modified by the layout. The snap to center behavior can be switched off by modifying the snapToCenter var to false.

To be infinite scrollable the data source must contains an amount of items so that the size of the collectionView would be at least 1.5 the screen size. The layout will not repeat the elements so that the same items are never visible twice at the same time on screen. In cases where the data source is not suitable for an infinite scroll behavior, the LNZInfiniteCollectionViewLayout will fallback on the LNZSnapToCenterCollectionViewLayout behavior. (if the snap to center is disabled, it will remain disabled)

LNZCarouselCollectionViewLayout

LNZCarouselCollectionViewLayout

This is an LNZSnapToCenterCollectionViewLayout with the difference that the item considered in focus will appear on full scaled and all the other not in focus items will be scaled down proportionally to the distance from the center of the collectionView. The infinite scrolling can be disabled, as well as the snap to center behavior, by setting the properties isInfiniteScrollEnabled and snapToCenter to false. The scaling behavior can be customized to obtain the desired scale for items not in focus by changing the properties values scalingOffset and minimumScaleFactor.

scalingOffset represents the distance from the center after which all the items will appear scaled by minimumScaleFactor. The items in the center will always have a scale factor of 1.

lnzcollectionlayouts's People

Contributors

gringoiredm avatar

Watchers

John D. Pope avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.