Coder Social home page Coder Social logo

hossein7441 / infinite-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metafizzy/infinite-scroll

0.0 1.0 0.0 7.56 MB

[Unmaintained] jQuery and Wordpress plugins for infinite scroll

Home Page: http://www.infinite-scroll.com

JavaScript 53.43% Shell 0.33% HTML 11.38% CSS 4.85% PHP 30.01%

infinite-scroll's Introduction

Unfortunately this project is no longer maintained.

It's had strong contributors over the years but it's time to clearly set expectations. We are unlikely to ship a new version, add features or fix bugs.

IMO, the only way forward with this project is a 100% rewrite with a new API. If you're interested in owning that, please get in touch. ~ @paulirish, april 2015

PS. Thank you very much to all the contributors over the years. It's been a fun time helping the internet scroll their way to more good stuff. :)


Infinite Scroll

http://www.infinite-scroll.com/

The jQuery and WordPress Plugins:

##Methods## A method is a command you can use to control Infinite Scroll once the plugin has been initialized. You can call on any Infinite Scroll method by using $('.selector').infinitescroll('method-name');.

Bind
$('.selector').infinitescroll('bind');
Binds selector to check on scroll to see if the plugin needs to load more content.

Unbind
$('.selector').infinitescroll('unbind');
Unbinds selector to check on scroll to see if the plugin needs to load more content.

Destroy
$('.selector').infinitescroll('destroy');
Destroys the instance of infinite scroll. This is create a flag to not load anymore content and will unbind all events.

Pause
$('.selector').infinitescroll('pause');
Pausing the plugin will temporarily create a flag to not retrieve content on scroll. To unpause, use the method resume.

Resume
$('.selector').infinitescroll('resume');
Destroys the instance of infinite scroll. This is create a flag to not load anymore content and will unbind all events.

Toggle
$('.selector').infinitescroll('toggle');
Toggling will switch the pause value of the plugin, either pausing or resuming the plugin.

Retrieve
$('.selector').infinitescroll('retrieve');
Retrieve will load the next page of content if available.

Scroll
$('.selector').infinitescroll('scroll');
Scroll will check to see if the next page is to be loaded, the same thing as if a user scrolled.

Update
$('.selector').infinitescroll('update', {debug: true});
The update method is used to update options in the instance of Infinite Scroll after initialization. The second argument is the object of options that you want to update.

##Options## Better documentation coming soon.

$('.selector').infinitescroll({
  loading: {
    finished: undefined,
    finishedMsg: "<em>Congratulations, you've reached the end of the internet.</em>",
                img: null,
    msg: null,
    msgText: "<em>Loading the next set of posts...</em>",
    selector: null,
    speed: 'fast',
    start: undefined
  },
  state: {
    isDuringAjax: false,
    isInvalidPage: false,
    isDestroyed: false,
    isDone: false, // For when it goes all the way through the archive.
    isPaused: false,
    currPage: 1
  },
  behavior: undefined,
  binder: $(window), // used to cache the selector for the element that will be scrolling
  nextSelector: "div.navigation a:first",
  navSelector: "div.navigation",
  contentSelector: null, // rename to pageFragment
  extraScrollPx: 150,
  itemSelector: "div.post",
  animate: false,
  pathParse: undefined,
  dataType: 'html',
  appendCallback: true,
  bufferPx: 40,
  errorCallback: function () { },
  infid: 0, //Instance ID
  pixelsFromNavToBottom: undefined,
  path: undefined, // Can either be an array of URL parts (e.g. ["/page/", "/"]) or a function that accepts the page number and returns a URL
  maxPage:undefined // to manually control maximum page (when maxPage is undefined, maximum page limitation is not work)
});

Examples

Scrolling inside an element

To scroll inside an element having overflow, use the local behavior.

$('.selector').infinitescroll({
  behavior: 'local',
  binder: $('.selector'), // scroll on this element rather than on the window
  // other options
});

Loading JSON data

As explained on the website, Infinite Scroll is designed for progressive enhancement, using existing pagination links. However, it is still possible to work with JSON data.

It means the nextSelector href will be called via AJAX, expecting JSON data, which will be passed to the callback function.

$('.selector').infinitescroll({
  // other options
  dataType: 'json',
  appendCallback: false
}, function(json, opts) {
  // Get current page
  var page = opts.state.currPage;
  // Do something with JSON data, create DOM elements, etc ..
});

License

The MIT License (MIT)

Copyright (c) 2014 Paul Irish

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.

infinite-scroll's People

Contributors

67726e avatar alexisabril avatar alexsegura avatar anthonydisanti avatar arief-hidayat avatar benbalter avatar defeated avatar ey-intuitive avatar fliespl avatar gsomoza avatar helgatheviking avatar jacopotarantino avatar jfache avatar jvanasco avatar kant avatar lentinj avatar lukeshumard avatar mgeraci avatar misiek08 avatar niftylettuce avatar nvartolomei avatar paladisco avatar paulirish avatar pawelstroinski avatar proudfoot avatar reggi avatar ryleyb avatar samcleaver avatar sparanoid avatar szepeviktor avatar

Watchers

 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.