Comments (7)
Your code in the first example should work. Do you have an example page?
Also, you should end the method call with a semicolon:
$("#makeMeScrollable").smoothDivScroll("startAutoScrolling");
but I don't think it has anything to do with this error.
from smooth-div-scroll.
Hello Thomas. Thanks for the reply!
Here is a test page with what I'm trying to do:
http://www.pratadesign.com.br/exemplos/
The problem is that after some use, the scroll stops working correctly.
from smooth-div-scroll.
I think that at least part of problem has to do with with keeping the internal state of the plugin in sync with the toggle button. Consider this:
- The plugin is autscrolling.
- The user moves the mouse over one of the hot spots. What happens (internally) is that Smooth Div Scroll stops the autoscrolling.
- Now you have a button that says "pause" to stop the auto scrolling, but since it has already been stopped clicking the button once won't do anything. You will have to click it twice to start the scrolling again. This is due to the toggle setting of the button.
To fix this you should rewrite the button code so instead of being just a toggle button it has to know if the scroller is running or not and change states after this. One way to accomplish this is to use the callbacks autoScrollingStopped and autoScrollingStarted.
Good luck!
from smooth-div-scroll.
Hi Thomas,
I'm doing exactly that. See how's the code:
$("#makeMeScrollable").smoothDivScroll({autoScrollingStopped: function(eventObj, data) {
$('#btn').text('play');
$('#btn').click(function(){
$("#makeMeScrollable").smoothDivScroll("startAutoScrolling")
});
}});
$("#makeMeScrollable").smoothDivScroll({autoScrollingStarted: function(eventObj, data) {
$('#btn').text('pause');
$('#btn').click(function(){
$("#makeMeScrollable").smoothDivScroll("stopAutoScrolling")
});
}});
It works for a while, but then the page starts to be slow and the play / pause button failure
from smooth-div-scroll.
Hmm, it sounds like you get some sort of memory leak or circular reference. The code in the latest example is not okay since you are initializing Smooth Div Scroll twice. Will this work? I just wrote down the code in a text editor but I can't test it:
var scrolling = true;
var Stopped = function(eventObj, data) {
$('#btn').text('play');
scrolling = false;
}
var Started = function(eventObj, data) {
$('#btn').text('pause');
scrolling = true;
}
$("#makeMeScrollable").smoothDivScroll({
autoScrollingStopped: Stopped,
autoScrollingStarted: Started
});
$('#btn').click(function(){
if(scrolling) {
$("#makeMeScrollable").smoothDivScroll("stopAutoScrolling");
} else {
$("#makeMeScrollable").smoothDivScroll("startAutoScrolling")
}
});
When seing how you use the plugin, an idea would be to provide a public method for getting the current status of the plugin. In its simplest form it could be isAutoScrolling that returned true or false. It could also be more advanced and return a JSON object with all kinds of status codes. There is one such method today (getScrollerOffset).
from smooth-div-scroll.
Thanks Thomas. Now ist's works.
from smooth-div-scroll.
Okay! Glad it worked out for you. I'm closing this issue now.
from smooth-div-scroll.
Related Issues (20)
- jScrollPane and Smooth Div Scroll
- Click to center image function not working in scroll gallery HOT 1
- How to change horizontal scroll to vertical scroll in Smooth Div Scoll HOT 2
- Responsive Height
- scroll stopping when mouse out from left and right icons
- I've used this as a navbar on mobile devices and it's worked great until recently...
- Wrong setting when using kinetic.js
- Uncaught TypeError: Cannot read property 'show' of undefined HOT 2
- HTML5 Validation Messages Not Displayed
- Enable vertical Page-Scrolling HOT 4
- Can we use this plugin in commercial website? Is it free? Thanks. HOT 1
- pauseOnHover option when autoScrollingMode: "always" is applied HOT 1
- Still cannot click on href on touchscreens HOT 1
- The last div doesn't show up
- When touch scrolling is enabled, links within an individual block aren't clickable
- Auto Scroll Speed when Mouse approaches ARROWS
- jQuery 3 broke plugin... HOT 2
- Uncaught TypeError: $(...).smoothDivScroll is not a function HOT 1
- Uncaught TypeError: $(...).smoothDivScroll is not a function HOT 1
- Can possible to provide React integration example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smooth-div-scroll.