Skip to content

Conversation

@tu-vu-duy
Copy link
Contributor

I fixed problem about 'speed' when set default it is 'auto'.

  • Old logic:
    speed very slow when move scroll has delta is small. But it very quickly when go to bottom to top because it has value is 0.
  • New logic:
    speed calculate by delta of scroll move. So it always run normally, not quickly/slow when move scroll.
    See test: http://svbuichu.com/javascript/ipad-test/

Other problem I found:
Now, when I used it on Ipad2, sometime, it do not work when click next action to scroll.

@kswedberg
Copy link
Owner

Thanks for this. I'll have to test the effect of your change when I get a chance. I'm also going to leave a couple line notes on the pull request diff.

I don't entirely understand what you mean by "Now, when I used it on Ipad2, sometime, it do not work when click next action to scroll." Questions:

  1. When you write "Now," do you mean before your change or after your change or both?
  2. "sometime": Is there a pattern to when it does not work versus when it does?
  3. "when click next action to scroll": What does "next action to scroll" mean?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wrap the value in parentheses?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) We can remove parentheses

Only use: var delta = aniProps[scrollDir] - $scroller.scrollTop();

I wrap the value in parentheses because, for me understand that: it is one value.

@tuvd08
Copy link

tuvd08 commented Oct 25, 2012

Back to my question relate to IPad2.

1/ "Now" it is before my changed and after my change.
2/ You can test on IPad2 in my test http://svbuichu.com/javascript/ipad-test/
3/ When I click to button B, after that I click button C or D, it not work.

  • After research on google, I see it is problem by safari on IOS-6, and then I see again your test, I see you have tip/chick about it by apply this code:
    {code}
    var $stupid = $('

    ')
    .height(1)
    .hide()
    .appendTo('body');

    var mobileHack = function() {
    $stupid.show();
    setTimeout(function() {
    $stupid.hide();
    }, 10);
    };
    $('ul.mainnav a').smoothScroll({
    afterScroll: mobileHack
    });

{/code}

However, I have new idea about it. you can see :

{code}
aniOpts = {
duration: speed,
easing: opts.easing,
complete: function() {
opts.afterScroll.call(opts.link, opts);
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if(isiPad) {
fixedElement.css({ "position": "relative", 'top':aniProps[scrollDir] , 'left': 10});
window.scroll(0, aniProps[scrollDir] );
fixedElement.css({ "position": "fixed", 'top': 0, 'left':0 });
}
}
};
{/code}

Replace line from 183 to 189.

@tuvd08
Copy link

tuvd08 commented Oct 25, 2012

I update code by your comment in this committed: focusjs@bd573bb

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for comment text:
//'delta' is a storage variable for the difference in offsets between // $scroller.scrollTop() , and aniProps[scrollDir] .

@travco
Copy link

travco commented Jul 31, 2014

I hate to see a pull request rot, despite it being a minor functionality change.

@kswedberg: Is there nothing missing before this can be merged, or is it not worth fiddling with and should be just closed (been open for almost 2 years) ?

@kswedberg kswedberg closed this in 34cd172 Aug 11, 2014
kushsharma added a commit to kushsharma/jquery-smooth-scroll that referenced this pull request Apr 24, 2016
* Improve docs:

* Add index.html, auto-generated by a grunt task
* Note that smooth-scrolling to `<a name="foo">`
  doesn't work with $('a').smoothScroll(); must use
  $.smoothScroll() inside event handler instead.
* Add note about beforeScroll callback
* Clean up options object comments

* Clean up defaults object comments

* Rename (deprecated) component.json to bower.json

* Add preventDefault option and bump to 1.4.11.

* Closes kswedberg#44

* Add syntax highlighting for index.html

* Ensure scrollable element is set with proper direction

* Bumped version and updated dist files

* Update bbq demo

* Add "options" argument feature to get/set options after init

* Build files and bump version

* Update jquery.js

* Readme: Add note about setting options after init

* Avoid "Cannot call method 'replace' of undefined" error

* Update bower.json, package.json

* Fix value of 'speed' when set default is 'auto'. Closes kswedberg#33

* Make jshint stricter and cleanup lint warnings

* Fix misspelling of autoCoefficient

* Release 1.5.0

* Avoid false positive on pathMatch when filtered link.pathname is empty string. Fixes kswedberg#64.

* Clean up package.json and Gruntfile.js and build files

* Release 1.5.1

* Update docs & fix out-of-sync versions for bower.json and jquery config json

* Indentation only

* Make plugin UMD-compliant (works with AMD, CommonJS, or neither). Clean up Gruntfile.

* Make plugin name consistent across package managers (and across my plugins)

* Escape slashes in hash. Fixes kswedberg#66.

* Release 1.5.4

* Add proper commonjs support. Closes kswedberg#74

* Add commonjs to build process and bump.

* Update readme with link to demo

* Remove moot `version` property from bower.json

Per bower/spec@a325da3

Also their maintainer says they probably won't ever use it: http://stackoverflow.com/questions/24844901/bowers-bower-json-file-version-property

* Remove bower.json from list of files to be revved on grunt version

* Add a few tests (finally). Many more needed.

* Remove smooth-scroll.jquery.json. No longer used.

* Add check for `document.scrollingElement`

* See https://dev.opera.com/articles/fixing-the-scrolltop-bug/

* Bower is dead. Long live npm.

* Ensure variable [scrollDir]() is used, not scrollTop(). Use Math.ab() instead of multiply by -1 if negative.

* Release 1.5.7

* Add optional support for event delegation

* Update docs and minor bump

* Request window location on every click.

* Since history.pushState exists, the location can change without a page reload.
* So, need to check link href against  window.location href every time.
* Closes kswedberg#89

* Update grunt plugins and bump version.

* Add grunt-jscs task

* Lint files with both jshint and jscs.

* Add contributing guidelines

* Add devel: true to jshint options

* Make plugin work in Firefox when CSS has `html {scroll-behavior: smooth;}`

* Update demos

* Fix uglifying.

* Build and bump to 1.6.2.

* Put Bower support (bower.json) back in. Fixes kswedberg#91

* Fix version from bad tag

* Bump for bower support and bad tag fix

* Ensure links to nonexistent elements don't trigger scroll. Fixes kswedberg#92.

* Add link to nonexistent element to demo and tests for avoiding scroll (and for scroll).

* Gruntfile: fix grunt-version config so everything gets correct version.

* Build and bump to 1.7.2.

* Update readme with a couple examples
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

Successfully merging this pull request may close these issues.

4 participants