1.0.12 • Published 7 years ago

@helios-interactive/budgie v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Budgie

An infinite scrolling plugin, that tackles grid layout of the items being scrolled, and can adapt as the list of items it is scrolling changes.

Demos

https://heliosinteractive.github.io/budgie/

Instalation

npm install @helios-interactive/budgie --save

Usage

Note:

Budgie element refers to the whole element, with all items contained inside of it.

Budgie item refers to a single items within the Budgie Element

Currently including the script file is the only way to use budgie.

Budgie will be available in the global namespace once it has been included with the script tag

<script src="node_modules/@helios-interactive/budgie/dist/budgie.min.js" type="text/javascript"></script>

To create a Budgie element, you will need a list of items that you want to make up the tiles within the Budgie element. You will also need to have an empty div on your page that will contain the Budgie element. You can also supply additional optional configuration as an options object

<script>
    new Budgie(items, '.element', options)
</script>

What can it display?

Budgie accepts three types of content as Budgie items.

  • Elements
    • Any HTMLElement can be passed as an item to budgie.
  • Images - as a source string
  • Videos - as a source string

You can send the whole list as one of these types, or mix and match them as desired.

How can I customize the styling?

Budgie intentionally does very little with styling so that the user can have full control of that aspect. All styles applied by budgie are applied as classes, so issues with specificty should be rare.

All Budgie items will have the class of budgie-item. You can use this to select the items and apply a class, or add your styling to that class.

The Budgie element will have a class of budgie-container

Can I have multiple Budgie containers on the same page?

Yep. Each Budgie will generate a code to keep it uniquely identified. This is stored on the Budgie object as budgieId

If you have multiple budgie elements, then you can use the budgieId to select the one you want. Budgie items will have the class budgie-item-<budgieId>. The Budgie element will have the class budgie-container-<budgieId>

Configuration

Configuration options are passed on initialization as an options object.

OptionTypeChoicesDefaultDescription
numberHighInteger1...n1This determines the number of Budgie items that will be stacked vertically.
numberWideInteger1...n1This determines the number of Budgie items that will be stacked horizontally.
directionString'vertical', 'horizontal''vertical'This will set which axis the Budgie element will scroll on.
invertedBooleantrue, falsefalseBy default horizontal will scroll from left to right, and vertical will scroll from top to bottom. This will invert those directions so that horizontal will scroll from right to left, and vertical will scroll from bottom to top. This is only used if autoScroll is true.
fpsInteger1...n60This determines how often Budgie animates. A higher fps will provide a smoother animation, at the cost of performance. Between 30 and 60 is usually optimal. This is only used if autoScroll is true.
secondsOnPageFloat1.0...n1.0This determines how long a Budgie Item stays within the Budgie element (how long the viewer can see it before it goes off screen). The lower the number, the faster it will go. This combined with the size of the Budgie Element will determine the speed of the scroll. This is only used if autoScroll is true.
infiniteScrollBooleantrue, falsetrueIf this is set to true, then scrolling will wrap around allowing for infinite scrolling (scrolling down will wrap around and put you at the top, or vice versa).
autoScrollBooleantrue, falsetrueIf autoScroll is on, then Budgie will automatically scroll through the elements using the secondsOnPage and Budgie element size to determine speed.
autoStartBooleantrue, falsetrueIf this is true, then the Budgie element will automatically start on new Budgie. Otherwise it can be manually started with Budgie.budgieAnimate() This is only used if autoScroll is true.

Methods available

The following methods are available on the Budgie object that is returned from new Budgie.

MethodArgumentsDescription
setItemsitems - the array of items that you want budgie to displayThis method will compare the items passed as arguments, to Budgie's previous set of items. It will then update Budgie, adding/removing elements where needed.
budgieAnimateWill start Budgie autoscrolling
stopAnimateWill stop Budgie from autoscrolling
changeInversionWill toggle the inversion to the opposite of it's current setting
removeBudgieWill remove the budgie element from the dom. It cannot be added back, and will need replaced with a new Budgie

The following array methods will update the Budgie element if executed on the array of items passed to budgie.

MethodDescription
popNormal Array behavior. Will pop the associated element off of Budgie
pushNormal Array behavior. Will push the associated element onto Budgie
shiftNormal Array behavior. Will shift the associated element off of Budgie
unshiftNormal Array behavior. Will unshift the associated element off of Budgie
spliceNormal Array behavior. Will splice the associated element(s) on/off of Budgie

Browser support

  • IE11
  • Edge11
  • Chrome 49
  • Opera 42
  • Safari 9.2
  • Firefox 50
  • Sorry, no Netscape Navigator or Lynx support :/

For more support add:

License

MIT License

Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago