Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7057bc7

Browse files
committed
updatemenus: make ScrollBox#setTranslate public
1 parent 8df8fd6 commit 7057bc7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/updatemenus/scrollbox.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ ScrollBox.prototype.enable = function enable() {
249249
}
250250

251251
// set initial position
252-
this._setTranslate(0, 0);
252+
this.setTranslate();
253253
};
254254

255255
/**
@@ -304,7 +304,7 @@ ScrollBox.prototype._onBoxDrag = function onBarDrag() {
304304
}
305305
else yf = 0;
306306

307-
this._setTranslate(xf, yf);
307+
this.setTranslate(xf, yf);
308308
};
309309

310310
/**
@@ -338,17 +338,20 @@ ScrollBox.prototype._onBarDrag = function onBarDrag() {
338338
}
339339
else yf = 0;
340340

341-
this._setTranslate(xf, yf);
341+
this.setTranslate(xf, yf);
342342
};
343343

344344
/**
345345
* Set clip path and scroll bar translate transform
346346
*
347347
* @method
348-
* @param {number} xf Horizontal position as a container fraction
349-
* @param {number} yf Vertical position as a container fraction
348+
* @param {number} [xf=0] Horizontal position as a container fraction
349+
* @param {number} [yf=0] Vertical position as a container fraction
350350
*/
351-
ScrollBox.prototype._setTranslate = function _setTranslate(xf, yf) {
351+
ScrollBox.prototype.setTranslate = function setTranslate(xf, yf) {
352+
xf = Lib.constrain(xf || 0, 0, 1);
353+
yf = Lib.constrain(yf || 0, 0, 1);
354+
352355
// store xf and yf (needed by ScrollBox.prototype._on*Drag)
353356
this._xf = xf;
354357
this._yf = yf;

0 commit comments

Comments
 (0)