Skip to content

Commit 1295cfe

Browse files
committed
squashed cubic-bezier unit tests
1 parent b6b6f04 commit 1295cfe

File tree

4 files changed

+601
-42
lines changed

4 files changed

+601
-42
lines changed

src/extensions/default/CSSCodeHints/CSSProperties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"animation-iteration-count": {"values": ["infinite"]},
1111
"animation-name": {"values": ["none"]},
1212
"animation-play-state": {"values": ["paused", "running"]},
13-
"animation-timing-function": {"values": ["cubic-bezier()", "ease", "ease-in", "ease-in-out", "ease-out", "linear", "step-end", "step-start", "steps()"]},
13+
"animation-timing-function": {"values": ["cubic-bezier(.42, 0, .58, 1)", "ease", "ease-in", "ease-in-out", "ease-out", "linear", "step-end", "step-start", "steps()"]},
1414
"backface-visibility": {"values": ["hidden", "visible"]},
1515
"background": {"values": []},
1616
"background-attachment": {"values": ["fixed", "local", "scroll", "inherit"]},
@@ -189,7 +189,7 @@
189189
"transition-delay": {"values": []},
190190
"transition-duration": {"values": []},
191191
"transition-property": {"values": ["all", "none"]},
192-
"transition-timing-function": {"values": ["cubic-bezier()", "ease", "ease-in", "ease-in-out", "ease-out", "linear", "step-end", "step-start", "steps()"]},
192+
"transition-timing-function": {"values": ["cubic-bezier(.42, 0, .58, 1)", "ease", "ease-in", "ease-in-out", "ease-out", "linear", "step-end", "step-start", "steps()"]},
193193
"unicode-bidi": {"values": ["bidi-override", "embed", "normal", "inherit"]},
194194
"unicode-range": {"values": []},
195195
"vertical-align": {"values": ["baseline", "bottom", "middle", "sub", "super", "text-bottom", "text-top", "top", "inherit"]},

src/extensions/default/InlineTimingFunctionEditor/TimingFunctionEditor.js

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,8 @@ define(function (require, exports, module) {
290290
* @param {Event} e Mouse move event
291291
* @param {number} x New horizontal position
292292
* @param {number} y New vertical position
293-
* @param {left: number, top: number, width: number, height: number} curveBoundingBox
294293
*/
295-
function handlePointMove(e, x, y, curveBoundingBox) {
294+
function handlePointMove(e, x, y) {
296295
var self = e.target,
297296
bezierEditor = self.bezierEditor;
298297

@@ -323,7 +322,7 @@ define(function (require, exports, module) {
323322
// Constrain time (x-axis) to 0 to 1 range. Progression (y-axis) is
324323
// theoretically not constrained, although canvas to drawing curve is
325324
// arbitrarily constrained to -0.5 to 1.5 range.
326-
x = Math.min(Math.max(0, x), curveBoundingBox.width);
325+
x = Math.min(Math.max(0, x), WIDTH_MAIN);
327326

328327
if (bezierEditor.dragElement) {
329328
$(bezierEditor.dragElement).css({
@@ -348,13 +347,10 @@ define(function (require, exports, module) {
348347
* @param {Element} canvas <canvas> element
349348
* @param {number} x Horizontal position
350349
* @param {number} y Vertical position
351-
* @param {left: number, top: number, width: number, height: number} curveBoundingBox
352350
*/
353-
function updateTimeProgression(curve, x, y, curveBoundingBox) {
354-
var height = curveBoundingBox.height;
355-
356-
curve.parentNode.setAttribute("data-time", Math.round(100 * x / curveBoundingBox.width));
357-
curve.parentNode.setAttribute("data-progression", Math.round(100 * (3 * height / 4 - y) / (height * 0.5) - 50));
351+
function updateTimeProgression(curve, x, y) {
352+
curve.parentNode.setAttribute("data-time", Math.round(100 * x / WIDTH_MAIN));
353+
curve.parentNode.setAttribute("data-progression", Math.round(100 * ((HEIGHT_MAIN - y) / HEIGHT_MAIN)));
358354
}
359355

360356
/**
@@ -371,14 +367,14 @@ define(function (require, exports, module) {
371367
x = e.pageX - left,
372368
y = e.pageY - top - HEIGHT_ABOVE;
373369

374-
updateTimeProgression(self, x, y, curveBoundingBox);
370+
updateTimeProgression(self, x, y);
375371

376372
if (bezierEditor.dragElement) {
377373
if (e.pageX === 0 && e.pageY === 0) {
378374
return;
379375
}
380376

381-
handlePointMove(e, x, y, curveBoundingBox);
377+
handlePointMove(e, x, y);
382378
}
383379
}
384380

@@ -396,13 +392,13 @@ define(function (require, exports, module) {
396392
x = e.pageX - left,
397393
y = e.pageY - top - HEIGHT_ABOVE;
398394

399-
updateTimeProgression(bezierEditor.curve, x, y, curveBoundingBox);
395+
updateTimeProgression(bezierEditor.curve, x, y);
400396

401397
if (e.pageX === 0 && e.pageY === 0) {
402398
return;
403399
}
404400

405-
handlePointMove(e, x, y, curveBoundingBox);
401+
handlePointMove(e, x, y);
406402
}
407403

408404
/**
@@ -450,7 +446,7 @@ define(function (require, exports, module) {
450446
var $this = $(e.target),
451447
left = parseInt($this.css("left"), 10),
452448
top = parseInt($this.css("top"), 10),
453-
offset = (e.shiftKey ? 20 : 2),
449+
offset = (e.shiftKey ? 15 : 3),
454450
newVal;
455451

456452
switch (code) {
@@ -527,16 +523,16 @@ define(function (require, exports, module) {
527523
// redraw canvas
528524
this._updateCanvas();
529525

530-
this.curve.addEventListener("click", _curveClick, false);
531-
this.curve.addEventListener("mousemove", _curveMouseMove, false);
532-
this.P1.addEventListener("mousemove", _pointMouseMove, false);
533-
this.P2.addEventListener("mousemove", _pointMouseMove, false);
534-
this.P1.addEventListener("mousedown", _pointMouseDown, false);
535-
this.P2.addEventListener("mousedown", _pointMouseDown, false);
536-
this.P1.addEventListener("mouseup", _pointMouseUp, false);
537-
this.P2.addEventListener("mouseup", _pointMouseUp, false);
538-
this.P1.addEventListener("keydown", _pointKeyDown, false);
539-
this.P2.addEventListener("keydown", _pointKeyDown, false);
526+
$(this.curve).on("click", _curveClick);
527+
$(this.curve).on("mousemove", _curveMouseMove);
528+
$(this.P1).on("mousemove", _pointMouseMove);
529+
$(this.P2).on("mousemove", _pointMouseMove);
530+
$(this.P1).on("mousedown", _pointMouseDown);
531+
$(this.P2).on("mousedown", _pointMouseDown);
532+
$(this.P1).on("mouseup", _pointMouseUp);
533+
$(this.P2).on("mouseup", _pointMouseUp);
534+
$(this.P1).on("keydown", _pointKeyDown);
535+
$(this.P2).on("keydown", _pointKeyDown);
540536
}
541537

542538
/**
@@ -546,16 +542,16 @@ define(function (require, exports, module) {
546542

547543
this.P1.bezierEditor = this.P2.bezierEditor = this.curve.bezierEditor = null;
548544

549-
this.curve.removeEventListener("click", _curveClick, false);
550-
this.curve.removeEventListener("mousemove", _curveMouseMove, false);
551-
this.P1.removeEventListener("mousemove", _pointMouseMove, false);
552-
this.P2.removeEventListener("mousemove", _pointMouseMove, false);
553-
this.P1.removeEventListener("mousedown", _pointMouseDown, false);
554-
this.P2.removeEventListener("mousedown", _pointMouseDown, false);
555-
this.P1.removeEventListener("mouseup", _pointMouseUp, false);
556-
this.P2.removeEventListener("mouseup", _pointMouseUp, false);
557-
this.P1.removeEventListener("keydown", _pointKeyDown, false);
558-
this.P2.removeEventListener("keydown", _pointKeyDown, false);
545+
$(this.curve).off("click", _curveClick);
546+
$(this.curve).off("mousemove", _curveMouseMove);
547+
$(this.P1).off("mousemove", _pointMouseMove);
548+
$(this.P2).off("mousemove", _pointMouseMove);
549+
$(this.P1).off("mousedown", _pointMouseDown);
550+
$(this.P2).off("mousedown", _pointMouseDown);
551+
$(this.P1).off("mouseup", _pointMouseUp);
552+
$(this.P2).off("mouseup", _pointMouseUp);
553+
$(this.P1).off("keydown", _pointKeyDown);
554+
$(this.P2).off("keydown", _pointKeyDown);
559555
};
560556

561557

@@ -611,20 +607,20 @@ define(function (require, exports, module) {
611607
// handle special cases of cubic-bezier calls
612608
switch (match[0]) {
613609
case "linear":
614-
return [ 0, 0, 1, 1 ];
610+
return [ "0", "0", "1", "1" ];
615611
case "ease":
616-
return [ 0.25, 0.1, 0.25, 1 ];
612+
return [ ".25", ".1", ".25", "1" ];
617613
case "ease-in":
618-
return [ 0.42, 0, 1, 1 ];
614+
return [ ".42", "0", "1", "1" ];
619615
case "ease-out":
620-
return [ 0, 0, 0.58, 1 ];
616+
return [ "0", "0", ".58", "1" ];
621617
case "ease-in-out":
622-
return [ 0.42, 0, 0.58, 1 ];
618+
return [ ".42", "0", ".58", "1" ];
623619
}
624620
}
625621

626622
window.console.log("brackets-cubic-bezier: getCubicBezierCoords() passed invalid RegExp match array");
627-
return [ 0, 0, 0, 0 ];
623+
return [ "0", "0", "0", "0" ];
628624
};
629625

630626
/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* */
2+
3+
.foo {
4+
transition-timing-function: cubic-bezier(.42, 0, .58, 1);
5+
transition-timing-function: cubic-bezier(0, -0.2, 1, 1.3);
6+
transition-timing-function: linear;
7+
transition-timing-function: ease;
8+
transition-timing-function: ease-in;
9+
transition-timing-function: ease-out;
10+
transition-timing-function: ease-in-out;
11+
}
12+
13+
.bar {
14+
transition: width 1s cubic-bezier(.86, .11, .18, .86) 0s, height 500ms cubic-bezier(.27, .75, .78, .14) 100ms;
15+
}

0 commit comments

Comments
 (0)