in partnership with mediatemple

Ticket #394 (new defect)

Opened 9 months ago

Last modified 2 days ago

Patch to unbreak the back button when using SmoothScroll

Reported by: Steffen Owned by:
Type: defect Priority: minor
Milestone: Mootools version 1.3 Component: Core
Keywords: smoothscroll back button Cc:

Description

Currently when using SmoothScroll? you cannot use your browser´s back button to go back to your previous scroll position in the document. I´ve fixed this with the following patch. It fools the browser by temporarily changing the target´s id so that the browser cannot scroll jump to the target on its own, _but_correctly remembers the current scroll position so that you can use the back button.

I agree that this solution is not very elegant, but it solves this bug and even if you don´t apply it maybe it can serve as an inspiration.

--- mootools-debug.js      2007-08-11 20:24:23.000000000 +0200
+++ mootools-debug.js      2007-08-11 20:24:24.000000000 +0200
@@ -6549,16 +6549,17 @@
                        var anchor = link.href.substr(location.length);
                        if (anchor && $(anchor)) this.useLink(link, anchor);
                }, this);
-               if (!window.webkit419) this.addEvent('onComplete', function(){
-                       window.location.hash = this.anchor;
-               });
        },
 
        useLink: function(link, anchor){
-               link.addEvent('click', function(event){
+               link.addEvent('click', function(){
                        this.anchor = anchor;
                        this.toElement(anchor);
-                       event.stop();
+                       var anchor_el = $(anchor);
+                       anchor_el.id += '_';
+                       window.setTimeout(function(){
+                               anchor_el.id = anchor;
+                       }, 0);
                }.bindWithEvent(this));
        }

Change History

Changed 8 months ago by ibolmo

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Will be considered for 1.3's Plugin enhancements and move.

Changed 2 days ago by tomocchino

  • owner deleted
  • component set to Core
  • milestone set to Mootools version 1.3
Note: See TracTickets for help on using tickets.