Closed Antonio-Laguna closed 11 years ago
Same issue here
@Belelros I found an solution, but I'm not sure it's good to be merge.
Actually, I tried you solution but same error kept occur When the toc try to find scrollable element, it actually scroll it a little.
$('container').scrollTop() slightly differently works between safari javascript engine and other browsers.
safari needs time to scroll.
anyway here is my solution. I replace the findScrollableElement
with this code.
var scrollable;
findScrollable(opts.container, 'body', 'html');
function findScrollable(els){
for(var i = 0; i < arguments.length; i++){
$target = $(arguments[i]);
if($target.scrollTop() > 0){
scrollable = $target;
return;
}
$target.scrollTop(1);
}
setTimeout(function(){ decideScrollable(opts.container, 'body', 'html') }, 100);
};
var decideScrollable = function(){
for(var i = 0; i < arguments.length; i++){
$target = $(arguments[i]);
if($target.scrollTop() > 0){
scrollable = $target;
scrollable.scrollTop(0);
return;
}
}
};
Hi there!
I found that in Safari on latest version, you get an error when you do the following: First you start scrolling till one of the elements is highlighted, then you try to click an element and it should begin the scrolling but the following error arises:
TypeError: 'undefined' is not a function (evaluating 'scrollable.animate')
It seems that it loose the value of the
scrollable
within the closure.I've added this before the
animate
call and the issue is solved. If anyone knows a better solution it will be greatly appreciated: