Closed thaint closed 9 years ago
What do you mean by not working?
Hi darsain, I mean when i resize the window browser, The sly is still running, not destroy. Sorry for my bad English
Can you isolate it on jsfiddle so I can look at the exact issue?
Hi darsain, My live site: http://thaint.net/anvifoto/ Hope you can take a look on it Many thanks
The point of isolating issues on jsfiddle is to not force developers to spend time reverse engineering your websites. Often times while isolating an issue people realize that they were doing something wrong themselves, and fix it without having to bother anyone.
But I've looked into it anyway and,... so many issues with that code. Read comments:
// You are calling destroy() via jQuery proxy shorthand here,
// even though there is no Sly instance created yet.
// This block does essentially nothing.
if( $(window).width() <= 481 ){
$('#crazy').sly(false);
}
var $frame = $('#crazy');
imagesLoaded( '#crazy ul', function() {
// This is actually when Sly is initiated, but seeing that
// you are gonna use methods like reload(), you should do it via Sly
// constructor so you can have access to the instance.
$frame.sly({
horizontal: 1,
itemNav: 'basic',
smart: 1,
activateOn: 'click',
mouseDragging: 1,
touchDragging: 1,
releaseSwing: 1,
startAt: 0,
scrollBy: 1,
activatePageOn: 'click',
speed: 700,
elasticBounds: 1,
easing: 'easeOutExpo',
dragHandle: 1,
dynamicHandle: 1,
clickBar: 1,
});
});
// And here you are calling reload() without any sly.initialized checks,
// which will break stuff when called on destroyed Sly instance.
$(window).resize(function( e ) {
$frame.sly('reload');
});
Overall that code can't work, and will break even more stuff as people start resizing the window.
Closing as this is not an issue with Sly but a general question.
Hi guy, I try to destroy sly on small devices but it seems like not working My init: var $frame = $('#crazy');
Destroy: if( $(window).width() <= 769 ){ $('#crazy').sly(false); } Thanks