Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

the work continue ...

  • Loading branch information...
commit 148d665414f4c70812fb03b20505639eb09ecf83 1 parent 5687f73
@piwi authored
View
5 demo/demo_short_column.html
@@ -12,7 +12,7 @@
*/
//--><html>
<head>
- <title>single long column on the left - Scroll Followers demo</title>
+ <title>single short column on the left - Scroll Followers demo</title>
<style type="text/css">
/* Some styles for this page only */
*{ padding:0; margin:0; }
@@ -55,6 +55,9 @@
<script type="text/javascript">
$(document).ready( function(){
+ // Allow you to position the debugger box where you want ...
+// $.scrollFollow_debugger_settings.debugger_position = { top:0, left:0 };
+
// Some infos about the plugin
$.scrollfollow.infos(1);
View
1  demo/demo_short_column_horizontal.html
@@ -61,6 +61,7 @@
// Attach the plugin on #scrollingDiv
$("#scrollingDiv").scrollfollow({
limit: '#content',
+ follow: "horizontal",
// toptobottom: 'top',
// bottomtotop: 'top',
debug:true
View
2  demo/index.html
@@ -74,7 +74,7 @@
<li><a href="demo_long_column_right.html">One long column on the right</a></li>
<li><a href="demo_multi_columns.html">Two columns on the left</a></li>
<li><a href="demo_multi_columns_right.html">Two columns on the right</a></li>
- <li><a href="demo_multi_columns_aside.html">Two columns aroud a content</a></li>
+ <li><a href="demo_multi_columns_aside.html">Two columns surrounding content</a></li>
</ul>
</div>
<div class="column">
View
88 jquery.scrollfollow/jquery.scrollfollow.debugger.js
@@ -3,15 +3,13 @@
// singleton instance
var sfdbg_instance=null;
-
(function($,undefined) {
- $.fn.scrollFollow_debugger = function()
- {
-
- this.settings = {
+ $.scrollFollow_debugger_settings = {
+ // user over-writable
+ debugger_position: { top:0, right:0 },
// templates (sprintf like)
- debugger_wrapper: '<div style="top:0;right:0;position:fixed;background-color:#404040;width:160px;height:auto;min-height:80px;'
+ debugger_wrapper: '<div style="position:fixed;background-color:#404040;width:160px;height:auto;min-height:80px;'
+'color:#fff;font:9px/1em normal Verdana,Helvetica,Arial,sans-serif;padding:4px;'
+'-moz-border-radius: 6px;-webkit-border-radius:6px;filter:alpha(opacity=90);-moz-opacity:0.9;opacity:0.9;"'
+'id="scrollfollowdebugger"></div>',
@@ -21,37 +19,50 @@ var sfdbg_instance=null;
debugger_subtitleblock: '<p style="font-weight:bold;font-size:9px;text-align:left;">%s</p>',
debugger_toggableblock: '<div style="display:none;font-size:9px;text-align:left;" id="%s"></div>',
debugger_titlespan: '<span style="">%s</span>',
- debugger_spanred: '<span style="color:red" id="%s"></span>',
- debugger_spanyellow: '<span style="color:yellow" id="%s"></span>',
+ debugger_spanred: '<span style="color:#ff0000" id="%s"></span>',
+ debugger_spanyellow: '<span style="color:#ffff00" id="%s"></span>',
+ debugger_spangreen: '<span style="color:#00ff00" id="%s"></span>',
+ debugger_spanblue: '<span style="color:#0099ff" id="%s"></span>',
debugger_listul: '<ul style="margin:0px 0px 2px 12px;padding:0px;">%s</ul>',
debugger_listli: '<li style="margin:0px 0px 4px 0px;padding:0px;list-style-type:disc;">%s</li>',
// strings
debugger_title: $.scrollfollow.name+' debugger',
- debugger_info_handler: '<a href="#" onclick="$(\'#sfdbg_infos\').toggle(\'slow\');return false;"'
- +'title="See versions informations" style="color:#fff">[Infos]</a>',
- debugger_sources_handler: '<a href="'+$.scrollfollow.sources+'" target="_blank" title="See plugin sources on GitHub"'
- +'style="color:#fff">[Sources]</a>',
- debugger_options_handler: '<a href="#" onclick="$(\'#%s\').toggle(\'slow\');return false;" title="See instance options"'
- +'style="color:#fff">[options]</a>',
+ debugger_info_handler: '[ <a href="#" onclick="$(\'#sfdbg_infos\').toggle(\'slow\');return false;"'
+ +'title="Show/Hide versions informations" style="color:#0099ff;text-decoration:none">Infos</a> ]',
+ debugger_sources_handler: '[ <a href="'+$.scrollfollow.sources+'" target="_blank" title="See plugin sources on GitHub"'
+ +'style="color:#0099ff;text-decoration:none;">Sources</a> ]',
+ debugger_options_handler: '[ <a href="#" onclick="$(\'#%s\').toggle(\'slow\');return false;" title="Show/Hide instance options"'
+ +'style="color:#0099ff;text-decoration:none;">options</a> ]',
debugger_scroll_title: 'Screen scrolling',
+ debugger_scrollw_title: 'scroll way: ',
debugger_scrollx_title: 'scroll [x]: ',
debugger_scrolly_title: 'scroll [y]: ',
debugger_object_title: 'New object [ #%s ]',
debugger_positionx_title: 'position [x]: ',
debugger_positiony_title: 'position [y]: ',
debugger_status_title: 'style: '
- };
+ };
+
+ $.fn.scrollFollow_debugger = function()
+ {
+ // settings
+ this.settings = $.scrollFollow_debugger_settings;
+ // builder: full block
+ this.build_block = function(str){ return this.settings.debugger_outerblock.replace('%s', str); };
+ // builder: info span
+ this.build_span = function(setting_index, str){ var _span = this.settings[setting_index]; return _span ? _span.replace('%s', str) : str; };
// initialization (singleton)
this._init = function()
{
$('body').append( this.settings.debugger_wrapper );
sfdbg_instance.sfdbg = $('#scrollfollowdebugger');
-
+ for (prop in this.settings.debugger_position) {
+ sfdbg_instance.sfdbg.css(prop, this.settings.debugger_position[prop]);
+ }
sfdbg_instance.sfdbg.html(
this.build_block( this.build_span('debugger_titleblock', this.settings.debugger_title) )
);
-
var _info_str = this.build_span('debugger_subtitleblock', this.settings.debugger_info_handler + '&nbsp;&nbsp;' + this.settings.debugger_sources_handler)
+ this.build_span('debugger_toggableblock', 'sfdbg_infos');
sfdbg_instance.sfdbg.append( this.build_block( _info_str ) );
@@ -67,10 +78,11 @@ var sfdbg_instance=null;
// scroll block
this._init_scroll = function()
{
- var _idx = 'scroll_posx',
- _idy = 'scroll_posy';
-
+ var _idx = 'scroll_posx', _idy = 'scroll_posy', _idw = 'scroll_way';
var _scroll_str = this.build_span('debugger_subtitleblock', this.settings.debugger_scroll_title)
+ + this.build_span('debugger_innerblock',
+ this.build_span('debugger_titlespan', this.settings.debugger_scrollw_title) + this.build_span('debugger_spangreen', _idw)
+ )
+ this.build_span('debugger_innerblock',
this.build_span('debugger_titlespan', this.settings.debugger_scrollx_title) + this.build_span('debugger_spanyellow', _idx)
)
@@ -79,11 +91,10 @@ var sfdbg_instance=null;
);
sfdbg_instance.sfdbg.append( this.build_block( _scroll_str ) );
-
var $this = $(this), _this_ = this;
$(window).bind('scroll', function(){
_this_.updateInfos(
- $(window).scrollTop(), $(window).scrollLeft(), null, {idx: _idx, idy: _idy}
+ $(window).scrollTop(), $(window).scrollLeft(), SCROLLFOLLOW_SCROLLING_WAY, {idx: _idx, idy: _idy, ids: _idw}
);
});
};
@@ -92,20 +103,14 @@ var sfdbg_instance=null;
this._init_object = function()
{
var _id = $(this).attr('id') || '',
- _idx = 'sfdiv_posx_'+_id,
- _idy = 'sfdiv_posy_'+_id,
- _ids = 'sfdiv_status_'+_id,
- _ido = 'sfdiv_options_'+_id,
- _opts = $(this).data("scrollfollow_debugger.options");
- sfdbg_instance._id={};
-
- var _obj_opts_str_items = '';
+ _idx = 'sfdiv_posx_'+_id, _idy = 'sfdiv_posy_'+_id,
+ _ids = 'sfdiv_status_'+_id, _ido = 'sfdiv_options_'+_id,
+ _opts = $(this).data("scrollfollow_debugger.options"),
+ _obj_opts_str_items = '';
for (var key in _opts) {
- _obj_opts_str_items +=
- this.build_span('debugger_listli', key+'= '+_opts[key]);
+ _obj_opts_str_items += this.build_span('debugger_listli', key+'= '+_opts[key]);
}
var _obj_opts_str = this.build_span('debugger_listul', _obj_opts_str_items);
-
var _obj_str = this.build_span('debugger_subtitleblock', this.build_span( 'debugger_object_title', _id) )
+ this.build_span('debugger_innerblock',
this.build_span('debugger_titlespan', this.settings.debugger_positionx_title) + this.build_span('debugger_spanred', _idx)
@@ -121,7 +126,6 @@ var sfdbg_instance=null;
sfdbg_instance.sfdbg.append( this.build_block( _obj_str ) );
$('#'+_ido).html( _obj_opts_str );
-
var $this = $(this), _this_ = this;
$(window).bind('scroll', function(){
_this_.updateInfos(
@@ -138,20 +142,7 @@ var sfdbg_instance=null;
if (status!=undefined && status!=null) $('#'+divs['ids']).html(status);
};
- // builder: full block
- this.build_block = function( str )
- {
- return this.settings.debugger_outerblock.replace('%s', str);
- };
-
- // builder: info span
- this.build_span = function( setting_index, str )
- {
- var _span = this.settings[setting_index];
- return _span.replace('%s', str);
- };
-
- // plugin work
+ // plugin work ...
if (this.length){
var _this_ = this;
return this.each(function(){
@@ -165,7 +156,6 @@ var sfdbg_instance=null;
return this;
});
}
-
};
})(jQuery);
View
372 jquery.scrollfollow/jquery.scrollfollow.js
@@ -1,5 +1,9 @@
/**
*/
+
+// as it is unique, the scrolling way is stored in a global
+var SCROLLFOLLOW_SCROLLING_WAY=null;
+
(function($,undefined) {
var
@@ -7,6 +11,7 @@
SFNAME="scrollfollow";
function ScrollFollow(){
+ this.isFixed=false;
this.defaults = {
speed: 0,//"slow",
top: 10,
@@ -31,8 +36,8 @@
// plugin infos
infos: function(dbg){
- if (dbg && dbg=='version') {
- return $.scrollfollow.version;
+ if (dbg && typeof dbg == 'string') {
+ return $.scrollfollow[dbg] ? $.scrollfollow[dbg] : null;
} else {
var fbi = $.scrollfollow.name+' [version '+$.scrollfollow.version+'] | see: <'+$.scrollfollow.sources+'>';
if (dbg && window.console) { window.console.info(fbi); }
@@ -70,94 +75,15 @@
$.data(inst, "scrollfollow_debugger.options", inst.options);
if (inst.debugger_instance==undefined) inst.debugger_instance = inst.element.scrollFollow_debugger();
}
- this.locator( e );
+ this._locator( e );
inst.window.bind('scroll', function() {
- inst.self.scrollingWayFct( e );
+ scrollingWay();
inst.self.positionElement( e, inst.window );
});
},
-// -----------------
-// GETTERS / SETTERS
-// -----------------
-
- // get an option
- _get: function(inst, name){
- return inst.options[name] !== undefined ? inst.options[name] : this.defaults[name];
- },
-
- // get a CSS value
- _get_css: function(e, k, isInt){
- var inst = this._getInstance(e);
- if (!inst) { return false; }
- if (isInt) {
- return parseInt(inst.element.css(k).replace(/auto/,0), 10) || 0;
- } else {
- return inst.element.css(k) || false;
- }
- },
-
- // set a CSS value
- _set_css: function(e, k, v){
- var inst = this._getInstance(e);
- if (inst) {
- _dbg('Setting "'+k+'" of element on: '+v);
- inst.element.css(k, v);
- }
- },
-
- // get a $.data FlaotingBox instance
- _getInstance: function(e) {
- try {
- return $.data(e, SFNAME);
- } catch (err) {
- throw 'No instance data for this floating box';
- }
- },
-
- // set or get options
- _option: function (e, name, value){
- var inst = this._getInstance(e);
- if (!inst) { return false; }
- if (value!=undefined) {
- inst.options[name] = value;
- $.data(e, SFNAME, inst);
- } else {
- return inst.options[name] || null;
- }
- },
-
- // set or get defaults options
- _defaults: function (name, value){
- if (value!=undefined) {
- this.defaults[name] = value;
- } else {
- return this.defaults[name] || null;
- }
- },
-
-// -----------------
-// USER & PLUGIN METHODS
-// -----------------
-
- // wrap the follower in a security div
- wrap: function(){
- var _clone = this.element.clone().css('position', 'absolute').html('');
- this.element
- .wrap( _clone )
- .css({width: '100%', margin: 0, padding: 0});
- },
-
- // delete the secrurity wrapper
- unwrap: function(){
- this.element
- .unwrap('<'+(_this.element[0].nodeName || 'div')+'/>')
- .css({width: _this.original.width, margin: _this.original.margin, padding: _this.original.padding});
- },
-
// locator: store some instance values (original css, limits) & find the parent
- locator: function (e){
-_dbg('locator');
+ _locator: function (e){
var inst = this._getInstance(e);
if (!inst) { return false; }
@@ -199,7 +125,7 @@ _dbg('locator');
if (_tmp.size()) {
inst.limiter = _tmp;
} else {
- $.error("'limit' option is not a jQuery selector ["+inst.options.limit+"]");
+ throw new Error("'limit' option is not a jQuery selector ["+inst.options.limit+"]");
}
}
inst.heights.limiter = inst.limiter.outerHeight();
@@ -217,9 +143,77 @@ _dbg('locator');
$.data(e, SFNAME, inst);
},
+// -----------------
+// GETTERS / SETTERS
+// -----------------
+
+ // get an option
+ _get: function(inst, name){
+ return inst.options[name] !== undefined ? inst.options[name] : this.defaults[name];
+ },
+
+ // get a CSS value
+ _get_css: function(e, k, isInt){
+ var inst = this._getInstance(e);
+ if (!inst) { return false; }
+ if (isInt) {
+ return parseInt(inst.element.css(k).replace(/auto/,0), 10) || 0;
+ } else {
+ return inst.element.css(k.replace('_', '-')) || false;
+ }
+ },
+
+ // set a CSS value
+ _set_css: function(e, k, v){
+ var inst = this._getInstance(e);
+ if (inst) {
+ _dbg('Setting "'+k+'" of element on: '+v);
+ inst.element.css(k.replace('_', '-'), v);
+ }
+ },
+
+ // is the instance fixed?
+ _isFixed: function(e){
+ var inst = this._getInstance(e);
+ return inst ? inst.isFixed : false;
+ },
+
+ // get a $.data FlaotingBox instance
+ _getInstance: function(e) {
+ try {
+ return $.data(e, SFNAME);
+ } catch (err) {
+ throw 'No instance data for this floating box';
+ }
+ },
+
+ // set or get options
+ _option: function (e, name, value){
+ var inst = this._getInstance(e);
+ if (!inst) { return false; }
+ if (value!=undefined && inst.options[name]) {
+ inst.options[name] = value;
+ $.data(e, SFNAME, inst);
+ } else {
+ return inst.options[name] || null;
+ }
+ },
+
+ // set or get defaults options
+ _defaults: function (name, value){
+ if (value!=undefined && this.defaults[name]) {
+ this.defaults[name] = value;
+ } else {
+ return this.defaults[name] || null;
+ }
+ },
+
+// -----------------
+// USER & PLUGIN METHODS
+// -----------------
+
// plugin logic: choose what to do depending on instance width & height and the scrolling way
positionElement: function (e, window){
-_dbg('positionElement');
var inst = this._getInstance(e);
if (!inst) { return false; }
@@ -227,8 +221,8 @@ _dbg('positionElement');
if (
inst.heights.self > inst.heights.screen &&
(
- (inst.scrollingWay=='down' && inst.options.toptobottom=='bottom') ||
- (inst.scrollingWay=='up' && inst.options.bottomtotop=='bottom')
+ (SCROLLFOLLOW_SCROLLING_WAY=='down' && inst.options.toptobottom=='bottom') ||
+ (SCROLLFOLLOW_SCROLLING_WAY=='up' && inst.options.bottomtotop=='bottom')
)
){
_limit = inst.limits.limiter_max - inst.heights.screen + inst.options.bottom;
@@ -240,35 +234,41 @@ _dbg('positionElement');
window.scrollTop() >= (inst.limits.self_max_secure - inst.heights.screen) &&
window.scrollTop() <= _limit
) {
- inst.self.switchEffect(e,
- window.scrollTop() - inst.heights.screen + inst.options.bottom,
- 'fixed',
- 'nullifnotempty',
- 0,
- inst.options.bottom,
- 0
- );
+ inst.isFixed=true;
+ inst.self.switchEffect(e, {
+ position: 'fixed',
+ margin: window.scrollTop() - inst.heights.screen + inst.options.bottom,
+ top: 'nullifnotempty',
+ margin_top: 0,
+ bottom: inst.options.bottom,
+ margin_bottom:0
+ });
// scroll is higher than limitor's height
} else if (
window.scrollTop() > _limit
) {
- inst.self.switchEffect(e,
- _margin,
- inst.original.position,
- 'nullifnotempty',
- _margin,
- 0,
- 0
- );
+ inst.isFixed=false;
+ inst.self.switchEffect(e, {
+ position: inst.original.position,
+ margin: _margin,
+ top: 'nullifnotempty',
+ margin_top: _margin,
+ bottom: 0,
+ margin_bottom:0
+ });
// scroll is lower than original top element's position
} else {
- inst.self.switchEffect(e,
- inst.original.margin_top, inst.original.position,
- inst.original.top, inst.original.margin_top,
- inst.original.bottom, inst.original.margin_bottom
- );
+ inst.isFixed=false;
+ inst.self.switchEffect(e, {
+ position: inst.original.position,
+ margin: inst.original.margin_top,
+ top: inst.original.top,
+ margin_top: inst.original.margin_top,
+ bottom: inst.original.bottom,
+ margin_bottom:inst.original.margin_bottom
+ });
}
// element is shorter than screen
@@ -282,54 +282,57 @@ _dbg('positionElement');
window.scrollTop() >= inst.limits.self_min_secure &&
window.scrollTop() <= _limit
) {
- inst.self.switchEffect(e,
- window.scrollTop() - (inst.limits.self_min - inst.options.bottom - inst.options.top) + inst.options.top,
- 'fixed',
- inst.options.top,
- 0
- );
+ inst.isFixed=true;
+ inst.self.switchEffect(e, {
+ position: 'fixed',
+ margin: window.scrollTop() - (inst.limits.self_min - inst.options.bottom - inst.options.top) + inst.options.top,
+ top: inst.options.top,
+ margin_top: 0
+ });
// scroll is higher than limitor's height
} else if (
window.scrollTop() > _limit
) {
- inst.self.switchEffect(e,
- _margin,
- inst.original.position,
- 0,
- _margin
- );
+ inst.isFixed=false;
+ inst.self.switchEffect(e, {
+ position: inst.original.position,
+ margin: _margin,
+ top: 0,
+ margin_top: _margin
+ });
// scroll is lower than original top element's position
} else {
- inst.self.switchEffect(e,
- inst.original.margin_top, inst.original.position, inst.original.top, inst.original.margin_top
- );
+ inst.isFixed=false;
+ inst.self.switchEffect(e, {
+ position: inst.original.position,
+ margin: inst.original.margin_top,
+ top: inst.original.top,
+ margin_top: inst.original.margin_top
+ });
}
}
},
// choose the effect depending on 'speed' option
- switchEffect: function (e, margin, position, top, margintop, bottom, marginbottom){
-_dbg('switchEffect');
+ switchEffect: function (e, data){
var inst = this._getInstance(e);
if (!inst) { return false; }
- if (position!=undefined && (!inst.options.speed || inst.options.speed==0)){
- inst.self.setPosition(e, position, top, margintop, bottom, marginbottom);
+ if ( data.position!=undefined && (!inst.options.speed || inst.options.speed==0) ){
+ inst.self.setPosition(e, data);
} else {
- inst.self.setMargin(e, margin);
+ inst.self.setMargin(e, (data.margin || 0));
}
},
// effect: set the margin (if speed is not 0)
setMargin: function (e, margin){
-_dbg('setMargin');
var inst = this._getInstance(e);
if (!inst) { return false; }
var cur_margin = inst.self._get_css(inst, 'margin-top', true);
-
if (cur_margin != margin){
if (!inst.options.speed || inst.options.speed==0) {
inst.self._set_css(inst, 'margin-top', margin);
@@ -344,41 +347,38 @@ _dbg('setMargin');
},
// effect: set positions (if speed is 0)
- setPosition: function (e, position, top, margintop, bottom, marginbottom){
-_dbg('setPosition');
+ setPosition: function (e, data){
var inst = this._getInstance(e);
if (!inst) { return false; }
// current values
- var cur_pos = inst.self._get_css(inst, 'position') || 'static',
- cur_top = inst.self._get_css(inst, 'top', true),
- cur_margintop = inst.self._get_css(inst, 'margin-top', true),
- cur_bottom = inst.self._get_css(inst, 'bottom', true),
- cur_marginbottom = inst.self._get_css(inst, 'margin-bottom', true);
+ var current={
+ position: inst.self._get_css(inst, 'position') || 'static',
+ top: inst.self._get_css(inst, 'top', true),
+ bottom: inst.self._get_css(inst, 'bottom', true),
+ left: inst.self._get_css(inst, 'left', true),
+ right: inst.self._get_css(inst, 'right', true),
+ margin_top: inst.self._get_css(inst, 'margin-top', true),
+ margin_bottom: inst.self._get_css(inst, 'margin-bottom', true),
+ margin_left: inst.self._get_css(inst, 'margin-left', true),
+ margin_right: inst.self._get_css(inst, 'margin-right', true)
+ };
// setting position
- if ( cur_pos != position ){
- if (top!=undefined && top!=null && cur_top != top) {
- if (top=='nullifnotempty') {
- inst.self._set_css(inst, 'top', '');
- } else {
- inst.self._set_css(inst, 'top', top);
- }
- }
- if (margintop!=undefined && margintop!=null && cur_margintop != margintop) {
- inst.self._set_css(inst, 'margin-top', margintop);
- }
- if (bottom!=undefined && bottom!=null && cur_bottom != bottom) {
- if (bottom=='nullifnotempty') {
- inst.self._set_css(inst, 'bottom', '');
- } else {
- inst.self._set_css(inst, 'bottom', bottom);
+ if ( data.position!=undefined && data.position!=null && current.position!=data.position ){
+ for (prop in current) {
+ if ( data[prop]!=undefined && data[prop]!=null && current[prop]!=data[prop] ) {
+ if ( data[prop]=='nullifnotempty' ) {
+ if ( current[prop]!=undefined && current[prop]!=null && current[prop]!='' && current[prop]!=0 ) {
+ inst.self._set_css(inst, prop, '');
+ }
+ } else {
+ inst.self._set_css(inst, prop, data[prop]);
+ }
}
}
- if (marginbottom!=undefined && marginbottom!=null && cur_marginbottom != marginbottom) {
- inst.self._set_css(inst, 'margin-bottom', marginbottom);
- }
- if (position=='fixed') {
+
+ if ( data.position=='fixed' ) {
// inst.self._set_css(inst, 'left', inst.original.left);
// inst.self._set_css(inst, 'margin-left', inst.original.left);
// inst.self._set_css(inst, 'float', 'none');
@@ -389,33 +389,29 @@ _dbg('setPosition');
// inst.self._set_css(inst, 'float', inst.original.float);
// inst.unwrap();
}
- inst.self._set_css(inst, 'position', position);
+ inst.self._set_css(inst, 'position', data.position);
}
$.data(e, SFNAME, inst);
},
- // inform about current scrolling
- scrollingWayFct: function(e){
- var inst = this._getInstance(e);
- if (!inst) { return false; }
+// -----------------
+// UTILS
+// -----------------
- _e = $(window);
- var initScrollTop = _e.scrollTop(), currentScrollTop = 0,
- initScrollLeft = _e.scrollLeft(), currentScrollLeft = 0;
- _e.scroll(function(evt){
- currentScrollTop = $(this).scrollTop();
- currentScrollLeft = $(this).scrollLeft();
- inst.scrollingWay = (initScrollTop !== currentScrollTop ) ? (
- (initScrollTop < currentScrollTop ) ? 'down' : 'up'
- ) : (
- (initScrollLeft < currentScrollLeft ) ? 'right' : 'left'
- );
- initScrollTop = currentScrollTop;
- initScrollLeft = currentScrollLeft;
- });
+ // wrap the follower in a security div
+ wrap: function(){
+ var _clone = this.element.clone().css('position', 'absolute').html('');
+ this.element
+ .wrap( _clone )
+ .css({width: '100%', margin: 0, padding: 0});
+ },
- $.data(e, SFNAME, inst);
+ // delete the secrurity wrapper
+ unwrap: function(){
+ this.element
+ .unwrap('<'+(_this.element[0].nodeName || 'div')+'/>')
+ .css({width: _this.original.width, margin: _this.original.margin, padding: _this.original.padding});
}
});
@@ -429,6 +425,24 @@ _dbg('setPosition');
window.console.log($.scrollfollow.name + ' (' + $.scrollfollow.version + ') : ' + str);
}
}
+ // inform about current scrolling
+ function scrollingWay()
+ {
+ var _e = $(window),
+ initScrollTop = _e.scrollTop(), currentScrollTop = 0,
+ initScrollLeft = _e.scrollLeft(), currentScrollLeft = 0;
+ _e.scroll(function(evt){
+ currentScrollTop = $(this).scrollTop();
+ currentScrollLeft = $(this).scrollLeft();
+ SCROLLFOLLOW_SCROLLING_WAY = (initScrollTop !== currentScrollTop ) ? (
+ (initScrollTop < currentScrollTop ) ? 'down' : 'up'
+ ) : (
+ (initScrollLeft < currentScrollLeft ) ? 'right' : 'left'
+ );
+ initScrollTop = currentScrollTop;
+ initScrollLeft = currentScrollLeft;
+ });
+ }
//
// reference the plugin for jQuery
@@ -451,7 +465,7 @@ _dbg('setPosition');
if ($.scrollfollow[options]!=undefined) {
$.scrollfollow[options].apply($.scrollfollow, [this].concat(_args));
} else {
- $.error("Argument '"+options+"' is not a jquery.scrollfollow event!");
+ throw new Error("Argument '"+options+"' is not a jquery.scrollfollow event!");
}
});
// we return false triggering events to avoid normal propagation ...
Please sign in to comment.
Something went wrong with that request. Please try again.