Skip to content

Commit 889c3ca

Browse files
hansonrhansonr
authored andcommitted
slider/scrollbar upgrade for visualAmount
1 parent 92c9856 commit 889c3ca

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

sources/net.sf.j2s.java.core/src/swingjs/jquery/jquery-ui-j2sslider.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103
});
104104
var val = normValueFromMouse(me, position, obj);
105105
var pixmouse = getPixelMouse(me, position, false);
106+
106107
var isAtEnd = !mouseOverHandle && (!me.isScrollBar ? 0 :
107108
pixmouse < 5 ? -1 : pixmouse > getPixelTotal(me) - 5 ? 1 : 0);
108-
109109
if (isAtEnd) {
110110
me.element.addClass(me.orientation === "horizontal" ?
111111
(isAtEnd == 1 ? "ui-j2sslider-at-right" : "ui-j2sslider-at-left")
@@ -162,7 +162,7 @@
162162
}
163163

164164
var getPixelTotal = function(me) {
165-
return (me.orientation == "horizontal" ? width(me) : height(me)) || 100;
165+
return (me.orientation == "horizontal" ? width(me) : height(me)) - me.visibleAdjust || 100;
166166
}
167167

168168
var postMouseEvent = function(me, xye, id) {
@@ -229,6 +229,9 @@
229229
this._mouseInit();
230230
this.isScrollBar = o.isScrollBar;
231231
this.handleSize = 0; // scrollbar only
232+
this.visibleAmount = 0;
233+
this.visibleAdjust = 0;
234+
this.visibleFraction = 0;
232235
this.handleFraction = 0;
233236
this.marginX = (o.isScrollBar ? 0 : 19); // from CSS - margin * 2 + border
234237
this.marginY = (o.isScrollBar ? 0 : 0);
@@ -595,13 +598,23 @@
595598
this._refreshValue();
596599
this._animateOff = false;
597600
break;
598-
case "handleSize":
601+
case "visibleAmount":
599602
this.isScrollBar = true;
600-
this.handleFraction = value;
603+
this.visibleAmount = value;
604+
var min = this._valueMin();
605+
var max = this._valueMax();
606+
var f = (value >= 0 && min + value <= max ?
607+
value * 1 / (max - min) : 0.1);
608+
this.visibleFraction = f;
609+
if (f < 0.1)
610+
f = 0.1;
611+
this.handleFraction = f;
612+
var hw = (this.orientation === "horizontal" ? width(this) : height(this));
601613
if (this.orientation === "horizontal")
602-
$(this.handles[0]).width(this.handleSize = value * width(this));
614+
$(this.handles[0]).width(this.handleSize = f * hw);
603615
else
604-
$(this.handles[0]).height(this.handleSize = value * height(this));
616+
$(this.handles[0]).height(this.handleSize = f * hw);
617+
this.visibleAdjust = (f - this.visibleFraction) * hw;
605618
this._animateOff = true;
606619
this._resetClass();
607620
this._refreshValue();
@@ -655,7 +668,7 @@
655668
if (val <= this._valueMin()) {
656669
return this._valueMin();
657670
}
658-
var max = Math.round((this._valueMax() - this._valueMin()) * (1-this.handleFraction) + this._valueMin());
671+
var max = Math.round(this._valueMax() - this.visibleAmount); //* (1-this.handleFraction)
659672
if (val >= max) {
660673
return max;
661674
}
@@ -696,8 +709,12 @@
696709
},
697710

698711
_refreshValue : function() {
699-
var lastValPercent, valPercent, value, valueMin, valueMax, oRange = this.options.range, o = this.options, that = this, animate = (!this._animateOff) ? o.animate
700-
: false, _set = {};
712+
var lastValPercent, valPercent, value, valueMin, valueMax;
713+
var o = this.options;
714+
var oRange = o.range;
715+
var that = this;
716+
var animate = (!this._animateOff) ? o.animate : false;
717+
var _set = {};
701718
if (this.options.values
702719
&& this.options.values.length) {
703720
this.handles

0 commit comments

Comments
 (0)