NAVIGATION
This shows you the differences between two versions of the page.
|
english:other-enhancements:mootools:to-top-link [2011/07/29 14:08] Knut Heermann (flip-flop) |
english:other-enhancements:mootools:to-top-link [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{indexmenu_n>10}} | + | {{indexmenu_n>20}} |
| - | ====== Back to Top Link ====== | + | ====== Back to Top Link button fade in/out ====== |
| **A Toplink button appears autom. on the side (fade in/out) when approximately 2/3 of the page length is reached by scrolling. ** | **A Toplink button appears autom. on the side (fade in/out) when approximately 2/3 of the page length is reached by scrolling. ** | ||
| Line 216: | Line 216: | ||
| } | } | ||
| </code> | </code> | ||
| + | |||
| + | \\ | ||
| \\ | \\ | ||
| Line 231: | Line 233: | ||
| ==== JS-Code ==== | ==== JS-Code ==== | ||
| - | **Version for Mootools V1.2**\\ | + | **Version 1.31 for Mootools V1.2**\\ |
| **File** ##template/lib/mootools/plugin-1.2/mootools.back-to-top-1.2.js## | **File** ##template/lib/mootools/plugin-1.2/mootools.back-to-top-1.2.js## | ||
| Line 237: | Line 239: | ||
| <code js|h mootools.back-to-top-1.2.js|h> | <code js|h mootools.back-to-top-1.2.js|h> | ||
| /** | /** | ||
| + | * -------------------------------------------------------------------------- | ||
| * back-to-top: unobtrusive global 'back to top' link using mootools 1.2.x | * back-to-top: unobtrusive global 'back to top' link using mootools 1.2.x | ||
| * | * | ||
| Line 242: | Line 245: | ||
| * and Nicolas Sanguinetti - http://nicolassanguinetti.info | * and Nicolas Sanguinetti - http://nicolassanguinetti.info | ||
| * | * | ||
| - | * version: 1.2 | + | * version: 1.3 |
| * released: November 11, 2007 | * released: November 11, 2007 | ||
| * last modified: February 27, 2009 | * last modified: February 27, 2009 | ||
| + | * version: 1.31 | ||
| + | * last modified: July 28, 2011 KH: http://phpwcms-howto.de | ||
| * | * | ||
| * This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. | * This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. | ||
| * http://creativecommons.org/licenses/by-sa/3.0/ | * http://creativecommons.org/licenses/by-sa/3.0/ | ||
| + | * -------------------------------------------------------------------------- | ||
| */ | */ | ||
| // hide the effect from IE6, better not having it at all than being choppy. | // hide the effect from IE6, better not having it at all than being choppy. | ||
| if (!Browser.Engine.trident4) { | if (!Browser.Engine.trident4) { | ||
| - | // element added onload for IE to avoid the "operation aborted" bug. not yet verified for IE8 as it's still on beta as of this modification. | + | // element added onload for IE to avoid the "operation aborted" bug. not yet verified for IE8 as it's still on beta as of this modification. |
| - | window.addEvent((Browser.Engine.trident ? 'load' : 'domready'), function(){ | + | window.addEvent((Browser.Engine.trident ? 'load' : 'domready'), function(){ |
| - | + | ||
| - | var target_opacity = 0.64; | + | var scrollUp = new Fx.Scroll(window); // +KH 28.07.2011 SmoothScroll |
| - | new Element('span', { | + | |
| - | 'id': 'back-to-top', | + | var target_opacity = 0.64; |
| - | 'styles': { | + | new Element('span', { |
| - | opacity: target_opacity, | + | 'id': 'back-to-top', |
| - | display: 'none', | + | 'styles': { |
| - | position: 'fixed', | + | opacity: target_opacity, |
| - | bottom: 0, | + | display: 'none', |
| - | right: 0, | + | position: 'fixed', |
| - | cursor: 'pointer' | + | bottom: 0, |
| - | }, | + | right: 0, |
| - | 'text': 'back to top', | + | cursor: 'pointer' |
| - | 'tween': { | + | }, |
| - | duration: 200, | + | 'text': 'back to top', |
| - | onComplete: function(el) { if (el.get('opacity') == 0) el.setStyle('display', 'none')} | + | 'tween': { |
| - | }, | + | duration: 600, |
| - | 'events': {'click': function() { | + | onComplete: function(el) { if (el.get('opacity') == 0) el.setStyle('display', 'none')} |
| - | if (window.location.hash) { window.location.hash = '#top'; } | + | }, |
| - | else { window.scrollTo(0, 0); } | + | 'events': {'click': function() { |
| - | }} | + | // if (window.location.hash) { window.location.hash = '#top'; } |
| - | }).inject(document.body); | + | // else { window.scrollTo(0, 0); } |
| - | + | ||
| - | window.addEvent('scroll', function() { | + | scrollUp.toTop(); //+KH: go to the top; |
| - | var visible = window.getScroll().y > (window.getSize().y * 0.8); | + | }} |
| - | if (visible == arguments.callee.prototype.last_state) return; | + | }).inject(document.body); |
| - | + | ||
| - | // fade if supported | + | |
| - | if (Fx && Fx.Tween) { | + | window.addEvent('scroll', function() { |
| - | if (visible) $('back-to-top').fade('hide').setStyle('display', 'inline').fade(target_opacity); | + | var visible = window.getScroll().y > (window.getSize().y * 0.7); |
| - | else $('back-to-top').fade('out'); | + | if (visible == arguments.callee.prototype.last_state) return; |
| - | } else { | + | |
| - | $('back-to-top').setStyle('display', (visible ? 'inline' : 'none')); | + | // fade if supported |
| - | } | + | if (Fx && Fx.Tween) { |
| - | + | if (visible) $('back-to-top').fade('hide').setStyle('display', 'inline').fade(target_opacity); | |
| - | arguments.callee.prototype.last_state = visible | + | else $('back-to-top').fade('out'); |
| - | }); | + | } else { |
| - | }); | + | $('back-to-top').setStyle('display', (visible ? 'inline' : 'none')); |
| + | } | ||
| + | |||
| + | arguments.callee.prototype.last_state = visible | ||
| + | }); | ||
| + | }); | ||
| } | } | ||
| Line 297: | Line 308: | ||
| \\ | \\ | ||
| - | **Version for Mootools V1.3**\\ | + | **Version 1.31 for Mootools V1.3**\\ |
| **File** ##template/lib/mootools/plugin-1.3/mootools.back-to-top-1.3.js## | **File** ##template/lib/mootools/plugin-1.3/mootools.back-to-top-1.3.js## | ||
| Line 305: | Line 316: | ||
| <code js|h mootools.back-to-top-1.3.js|h> | <code js|h mootools.back-to-top-1.3.js|h> | ||
| /** | /** | ||
| - | * back-to-top: unobtrusive global 'back to top' link using mootools 1.2.x | + | * -------------------------------------------------------------------------- |
| + | * back-to-top: unobtrusive global 'back to top' link using mootools 1.3.x | ||
| * | * | ||
| * copyright (c) 2007-2009 by gonchuki - http://blog.gonchuki.com | * copyright (c) 2007-2009 by gonchuki - http://blog.gonchuki.com | ||
| * and Nicolas Sanguinetti - http://nicolassanguinetti.info | * and Nicolas Sanguinetti - http://nicolassanguinetti.info | ||
| * | * | ||
| - | * version: 1.2 | + | * version: 1.3 |
| * released: November 11, 2007 | * released: November 11, 2007 | ||
| * last modified: February 27, 2009 | * last modified: February 27, 2009 | ||
| + | * version: 1.31 | ||
| + | * last modified: July 28, 2011 KH: http://phpwcms-howto.de | ||
| * | * | ||
| * This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. | * This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. | ||
| * http://creativecommons.org/licenses/by-sa/3.0/ | * http://creativecommons.org/licenses/by-sa/3.0/ | ||
| + | * -------------------------------------------------------------------------- | ||
| */ | */ | ||
| // hide the effect from IE6, better not having it at all than being choppy. | // hide the effect from IE6, better not having it at all than being choppy. | ||
| - | //-KH v1.2 if (!Browser.Engine.trident4) { | + | //-KH moo v1.2 if (!Browser.Engine.trident4) { |
| if (!(Browser.name == 'ie' && Browser.version == 6)) { | if (!(Browser.name == 'ie' && Browser.version == 6)) { | ||
| - | // element added onload for IE to avoid the "operation aborted" bug. not yet verified for IE8 as it's still on beta as of this modification. | + | // element added onload for IE to avoid the "operation aborted" bug. not yet verified for IE8 as it's still on beta as of this modification. |
| - | //-KH v1.2 window.addEvent((Browser.Engine.trident ? 'load' : 'domready'), function(){ | + | //-KH moo v1.2 window.addEvent((Browser.Engine.trident ? 'load' : 'domready'), function(){ |
| - | window.addEvent((Browser.name == 'ie' ? 'load' : 'domready'), function(){ | + | window.addEvent((Browser.name == 'ie' ? 'load' : 'domready'), function(){ |
| - | + | ||
| - | var target_opacity = 0.64; | + | var scrollUp = new Fx.Scroll(window); // +KH 28.07.2011 SmoothScroll |
| - | new Element('span', { | + | |
| - | 'id': 'back-to-top', | + | var target_opacity = 0.64; |
| - | 'styles': { | + | new Element('span', { |
| - | opacity: target_opacity, | + | 'id': 'back-to-top', |
| - | display: 'none', | + | 'styles': { |
| - | position: 'fixed', | + | opacity: target_opacity, |
| - | bottom: 0, | + | display: 'none', |
| - | right: 0, | + | position: 'fixed', |
| - | cursor: 'pointer' | + | bottom: 0, |
| - | }, | + | right: 0, |
| - | 'text': 'back to top', | + | cursor: 'pointer' |
| - | 'tween': { | + | }, |
| - | duration: 200, | + | 'text': 'back to top', |
| - | onComplete: function(el) { if (el.get('opacity') == 0) el.setStyle('display', 'none')} | + | 'tween': { |
| - | }, | + | duration: 600, |
| - | 'events': {'click': function() { | + | onComplete: function(el) { if (el.get('opacity') == 0) el.setStyle('display', 'none')} |
| - | if (window.location.hash) { window.location.hash = '#top'; } | + | }, |
| - | else { window.scrollTo(0, 0); } | + | 'events': {'click': function() { |
| - | }} | + | // if (window.location.hash) { window.location.hash = '#top'; } |
| - | }).inject(document.body); | + | // else { window.scrollTo(0, 0); } |
| - | + | ||
| - | window.addEvent('scroll', function() { | + | scrollUp.toTop(); //+KH: go to the top; |
| - | var visible = window.getScroll().y > (window.getSize().y * 0.8); | + | }} |
| - | if (visible == arguments.callee.prototype.last_state) return; | + | }).inject(document.body); |
| - | + | ||
| - | // fade if supported | + | |
| - | if (Fx && Fx.Tween) { | + | window.addEvent('scroll', function() { |
| - | if (visible) $('back-to-top').fade('hide').setStyle('display', 'inline').fade(target_opacity); | + | var visible = window.getScroll().y > (window.getSize().y * 0.7); |
| - | else $('back-to-top').fade('out'); | + | if (visible == arguments.callee.prototype.last_state) return; |
| - | } else { | + | |
| - | $('back-to-top').setStyle('display', (visible ? 'inline' : 'none')); | + | // fade if supported |
| - | } | + | if (Fx && Fx.Tween) { |
| - | + | if (visible) $('back-to-top').fade('hide').setStyle('display', 'inline').fade(target_opacity); | |
| - | arguments.callee.prototype.last_state = visible | + | else $('back-to-top').fade('out'); |
| - | }); | + | } else { |
| - | }); | + | $('back-to-top').setStyle('display', (visible ? 'inline' : 'none')); |
| + | } | ||
| + | |||
| + | arguments.callee.prototype.last_state = visible | ||
| + | }); | ||
| + | }); | ||
| } | } | ||
| </code> | </code> | ||
| Line 367: | Line 387: | ||
| \\ | \\ | ||
| + | \\ | ||
| ===== CSS ===== | ===== CSS ===== | ||
| Line 417: | Line 438: | ||
| \\ | \\ | ||
| - | ==== Download ==== | + | ===== Download ===== |
| + | Version 1.30: {{:deutsch:andere-erweiterungen:mootools:mootools_totop_v130.zip|}} | ||
| - | {{:deutsch:andere-erweiterungen:mootools:mootools_totop.zip|}} | + | Version 1.31: {{:deutsch:andere-erweiterungen:mootools:mootools_totop_v131.zip|}} //(with SmoothScroll)// |
| \\ | \\ | ||