mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +08:00
ff25efe185
* refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
111 lines
3.7 KiB
Plaintext
111 lines
3.7 KiB
Plaintext
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors */
|
|
.bezierEasingMixin() {
|
|
@functions: ~`(function() {
|
|
var NEWTON_ITERATIONS = 4;
|
|
var NEWTON_MIN_SLOPE = 0.001;
|
|
var SUBDIVISION_PRECISION = 0.0000001;
|
|
var SUBDIVISION_MAX_ITERATIONS = 10;
|
|
|
|
var kSplineTableSize = 11;
|
|
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
|
|
|
var float32ArraySupported = typeof Float32Array === 'function';
|
|
|
|
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
|
|
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
|
|
function C (aA1) { return 3.0 * aA1; }
|
|
|
|
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
|
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
|
|
|
|
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
|
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
|
|
|
|
function binarySubdivide (aX, aA, aB, mX1, mX2) {
|
|
var currentX, currentT, i = 0;
|
|
do {
|
|
currentT = aA + (aB - aA) / 2.0;
|
|
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
if (currentX > 0.0) {
|
|
aB = currentT;
|
|
} else {
|
|
aA = currentT;
|
|
}
|
|
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
return currentT;
|
|
}
|
|
|
|
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
|
|
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
|
|
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
if (currentSlope === 0.0) {
|
|
return aGuessT;
|
|
}
|
|
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
aGuessT -= currentX / currentSlope;
|
|
}
|
|
return aGuessT;
|
|
}
|
|
|
|
var BezierEasing = function (mX1, mY1, mX2, mY2) {
|
|
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
|
throw new Error('bezier x values must be in [0, 1] range');
|
|
}
|
|
|
|
// Precompute samples table
|
|
var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
|
|
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
for (var i = 0; i < kSplineTableSize; ++i) {
|
|
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
}
|
|
}
|
|
|
|
function getTForX (aX) {
|
|
var intervalStart = 0.0;
|
|
var currentSample = 1;
|
|
var lastSample = kSplineTableSize - 1;
|
|
|
|
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
intervalStart += kSampleStepSize;
|
|
}
|
|
--currentSample;
|
|
|
|
// Interpolate to provide an initial guess for t
|
|
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
var guessForT = intervalStart + dist * kSampleStepSize;
|
|
|
|
var initialSlope = getSlope(guessForT, mX1, mX2);
|
|
if (initialSlope >= NEWTON_MIN_SLOPE) {
|
|
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
} else if (initialSlope === 0.0) {
|
|
return guessForT;
|
|
} else {
|
|
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
}
|
|
}
|
|
|
|
return function BezierEasing (x) {
|
|
if (mX1 === mY1 && mX2 === mY2) {
|
|
return x; // linear
|
|
}
|
|
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
|
|
if (x === 0) {
|
|
return 0;
|
|
}
|
|
if (x === 1) {
|
|
return 1;
|
|
}
|
|
return calcBezier(getTForX(x), mY1, mY2);
|
|
};
|
|
};
|
|
|
|
this.colorEasing = BezierEasing(0.26, 0.09, 0.37, 0.18);
|
|
// less 3 requires a return
|
|
return '';
|
|
})()`;
|
|
}
|
|
// It is hacky way to make this function will be compiled preferentially by less
|
|
// resolve error: `ReferenceError: colorPalette is not defined`
|
|
// https://github.com/ant-design/ant-motion/issues/44
|
|
.bezierEasingMixin();
|