Smooth-Div-Scroll icon indicating copy to clipboard operation
Smooth-Div-Scroll copied to clipboard

Callbacks inside wrong test loop

Open css117 opened this issue 12 years ago • 10 comments

Hi Great script here.

I couldn't get any callback to work (except setupComplete). neither scrolledToLastElement nor scrollerRightLimitReached... even with a simple console.log test function.

I stuck my nose into your code and realised that triggered callbacks were made inside a test about hot spot visibility. I believe it should rather be triggered in your move function...

Anyway, I worked it out when I set hotSpotScrolling to true.

Thanks !!

css117 avatar Sep 30 '12 00:09 css117

Could you post your code? I think I can understand the problem better if I can see your setup. If you are using autoscrolling to scroll the content, there are different callbacks for when the left or right limit has been reached.

http://www.smoothdivscroll.com/callbacks.html#autoScrollingLeftLimitReached http://www.smoothdivscroll.com/callbacks.html#autoScrollingRightLimitReached

But I guess that wasn't the problem in this case?

tkahn avatar Oct 02 '12 09:10 tkahn

Indeed, I don't use autoscroll. The main callback I needed was scrollerRightLimitReached, triggered by mouse wheel or touch slide. If I set the option : $("#makeMeScrollable").SmoothDivScroll({ hotSpotScrolling: false });

the callback scrollerRightLimitReached is ignored :

$("#makeMeScrollable").SmoothDivScroll({ hotSpotScrolling: false, scrollerRightLimitReached : function() { console.log("right end is reached"); } });

In your code, this callback is triggered in a loop concerning hotspot. :)

css117 avatar Oct 02 '12 10:10 css117

Ah! I see. This is because mousewheel and touch scrolling has been added on much later and I haven't updated the callbacks. I'll look into this!

tkahn avatar Oct 02 '12 10:10 tkahn

And if you move your callback, it would be nice to implement a scrollerRightLimitSoon : almost the same, but triggered before the end is reached. It will allow to refill the content before the user realise it, and make the scroll look infinite. :) Thanks !

css117 avatar Oct 02 '12 11:10 css117

That callback could also be used for lazyload implementation could it not?

andrewminton avatar Oct 02 '12 15:10 andrewminton

if by lazyload you mean loading just before it's necessary, that's my point ;)

css117 avatar Oct 02 '12 15:10 css117

This is a new feature and I understand that it could be very useful. I will add these two items to my list of requested features:

  1. Make the plugin trigger scrollerRightLimitReached/scrollerLeftLimitReached with mousewheel and touch scrolling as well (bugfix).
  2. Add new callbacks that is triggered when the scroller reaches a certain point (preferably user defined in pixels) before the left or right end of the scroller (new feature).

tkahn avatar Oct 03 '12 07:10 tkahn

Well, I made my first fork (I hope I did it properly) for the callback before the end is reached. You can see the reasult plugged into a drupal here : http://circulart.fr/liste-des-artistes :)

css117 avatar Oct 03 '12 12:10 css117

Yes, your fork looks good! The only problem is that I have a working copy of the code that is not published here on GitHub (yet) and there are many other changes in that. So I will probably not merge but nevertheless it was great to see your implementation and I think I will use it!

tkahn avatar Oct 03 '12 12:10 tkahn

Apparently callbacks still aren't working in the current version... Any plans on fixing them?

AndreiBarsan avatar May 02 '13 17:05 AndreiBarsan