Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"reloading" scrolldepth #24

Closed
zepedrorocha opened this issue Mar 28, 2014 · 8 comments
Closed

"reloading" scrolldepth #24

zepedrorocha opened this issue Mar 28, 2014 · 8 comments

Comments

@zepedrorocha
Copy link

Hello. I'm using AngularJS page routing (Multiple Views). Since i don't refresh the entire webpage your code will unbind scroll event, eventually.

// If all marks already hit, unbind scroll event
      if (cache.length >= 4 + options.elements.length) {
        $window.off('scroll.scrollDepth');
        return;
      }

I wish I could "reload" the scrolldepth when the View is changed. I'm asking for some advise to find the best option. Thank you

@joaocc
Copy link

joaocc commented Apr 1, 2014

How about forking, create the fix, and the send a pull request? Thx

@robflaherty
Copy link
Owner

@zepedrorocha - I'm not familiar with the best practices for reinitializing jQuery plugins on ajax page loads but I think something like a "reset" or "reload" method makes sense.

(I've also had a few people ask about infinite scroll pages and for those I think the plugin might need a method to push new elements into the list of tracked elements.)

If you'd like to send a pull request that would be great.. otherwise I'll have a look at it soon :)

@robflaherty
Copy link
Owner

Will add this in the next iteration when I remove the jQuery dependency.

@nandy-andy
Copy link

Hi!

I had similar issues. And I resolved them in my fork.

We're creating single page application with Ember and we wanted to use your useful plugin 😸 The issue was with caching in your plugin and detaching scroll.scrollDepth event after reaching all points. The changes I implemented are rather simple:

  • I added a detachEventOnceCacheIsFull flag which is backward compatible but once set to false never detach the scroll event,
  • exposed a simple reset() method for resetting variables which should be the same as at the beginning after changing a view (cache, lastPixelDepth).

@robflaherty, should I create a pull request and you'll merge it? Or do you want to wait till you remove jQuery dependency and you'll go with your version?

@robflaherty
Copy link
Owner

@nandy-andy Thanks, I think this is great. I'm wondering if there's a way to achieve the reset without requiring a new plugin option (I'm worried about the plugin becoming overloaded with options). What if the reset method detached and then reattached the scroll event handler?

A pull request would be awesome. A lot of people have asked for this feature so I'd like to go ahead and include it in the next version.

@robflaherty
Copy link
Owner

@nandy-andy Hey, if you want to submit a pull request for the work you already did, I can merge it into a dev branch and I'll work on modifying it so it doesn't require adding a new plugin option. If not, no worries :)

@nandy-andy
Copy link

Yeah, sorry. I wanted to play with it more but recently it's hard to find time. The pull request has been created: PR#53

@robflaherty
Copy link
Owner

@nandy-andy Thanks for the help. Hoping to release this and some other features sometime in the next few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants