-
Notifications
You must be signed in to change notification settings - Fork 0
Reduce calls to .height() in slot.js #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: connected-sortables
Are you sure you want to change the base?
Changes from all commits
d9f6358
48f3a9e
cb2ccd9
304110e
f34b552
f2389a5
f6ebf80
76ba966
9669bb0
0775afe
da8fa43
840e090
e5221a7
5d0c520
6a61bd6
65743e6
c5dad12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import Ember from 'ember'; | ||
| import computed from 'ember-new-computed'; | ||
| import { computed } from '@ember/object'; | ||
| const { Mixin, $, run } = Ember; | ||
| const { Promise } = Ember.RSVP; | ||
|
|
||
|
|
@@ -103,6 +103,7 @@ export default Mixin.create({ | |
| */ | ||
| isAnimated: computed(function() { | ||
| let el = this.$(); | ||
| if (el === undefined || el === null) return false; | ||
| let property = el.css('transition-property'); | ||
|
|
||
| return /all|transform/.test(property); | ||
|
|
@@ -115,6 +116,7 @@ export default Mixin.create({ | |
| */ | ||
| transitionDuration: computed(function() { | ||
| let el = this.$(); | ||
| if (el === undefined || el === null) return 0; | ||
| let rule = el.css('transition-duration'); | ||
| let match = rule.match(/([\d\.]+)([ms]*)/); | ||
|
|
||
|
|
@@ -140,7 +142,9 @@ export default Mixin.create({ | |
| x: computed({ | ||
| get() { | ||
| if (this._x === undefined) { | ||
| let marginLeft = parseFloat(this.$().css('margin-left')); | ||
| let el = this.$() | ||
| if (el === undefined || el === null) return 0; | ||
| let marginLeft = parseFloat(el.css('margin-left')); | ||
| this._x = this.element.scrollLeft + this.element.offsetLeft - marginLeft; | ||
| } | ||
|
|
||
|
|
@@ -182,6 +186,7 @@ export default Mixin.create({ | |
| */ | ||
| width: computed(function() { | ||
| let el = this.$(); | ||
| if (el === undefined || el === null) return 0; | ||
| let width = el.outerWidth(true); | ||
|
|
||
| width += getBorderSpacing(el).horizontal; | ||
|
|
@@ -196,6 +201,7 @@ export default Mixin.create({ | |
| */ | ||
| height: computed(function() { | ||
| let el = this.$(); | ||
| if (el === undefined || el === null) return 0; | ||
| let height = el.outerHeight(); | ||
|
|
||
| let marginBottom = parseFloat(el.css('margin-bottom')); | ||
|
|
@@ -401,7 +407,9 @@ export default Mixin.create({ | |
|
|
||
| if (groupDirection === 'x') { | ||
| let x = this.get('x'); | ||
| let dx = x - this.element.offsetLeft + parseFloat(this.$().css('margin-left')); | ||
| let el = this.$() | ||
| if (el === undefined || el === null) return 0; | ||
| let dx = x - this.element.offsetLeft + parseFloat(el.css('margin-left')); | ||
|
|
||
| this.$().css({ | ||
| transform: `translateX(${dx}px)` | ||
|
|
@@ -410,8 +418,9 @@ export default Mixin.create({ | |
| if (groupDirection === 'y') { | ||
| let y = this.get('y'); | ||
| let dy = y - this.element.offsetTop; | ||
|
|
||
| this.$().css({ | ||
| let el = this.$() | ||
| if (el === undefined || el === null) return 0; | ||
| el.css({ | ||
| transform: `translateY(${dy}px)` | ||
| }); | ||
| } | ||
|
|
@@ -485,6 +494,7 @@ export default Mixin.create({ | |
| @private | ||
| */ | ||
| _complete() { | ||
| if (this.isDestroyed || this.isDestroying) return; | ||
| this.sendAction('onDragStop', this.get('model')); | ||
| this.set('isDropping', false); | ||
| this.set('wasDropped', true); | ||
|
|
@@ -539,9 +549,10 @@ function getX(event) { | |
| */ | ||
| function getBorderSpacing(el) { | ||
| el = $(el); | ||
|
|
||
| if (el === undefined || el === null) return 0; | ||
| let css = el.css('border-spacing'); // '0px 0px' | ||
| let [horizontal, vertical] = css.split(' '); | ||
| const [horizontal, initialVertical] = css.split(" "); | ||
| const vertical = initialVertical === undefined ? horizontal : initialVertical; | ||
|
Comment on lines
550
to
+555
|
||
|
|
||
| return { | ||
| horizontal: parseFloat(horizontal), | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,7 @@ export default class Gesture { | |||||||||||
| this.clientY = 0; | ||||||||||||
| this.listeners = []; | ||||||||||||
| this.isDestroyed = false; | ||||||||||||
| this.isInAnimationFrame = false; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -194,7 +195,14 @@ export default class Gesture { | |||||||||||
| this.dx = this.x - this.ox; | ||||||||||||
| this.dy = this.y - this.oy; | ||||||||||||
|
|
||||||||||||
| this.onUpdate(this); | ||||||||||||
| if (this.isInAnimationFrame === false){ | ||||||||||||
| this.isInAnimationFrame = true; | ||||||||||||
| window.requestAnimationFrame(() => { | ||||||||||||
|
Comment on lines
+199
to
+200
|
||||||||||||
| this.isInAnimationFrame = true; | |
| window.requestAnimationFrame(() => { | |
| let requestAnimationFrameFn = this.eventTarget.requestAnimationFrame || requestAnimationFrame; | |
| this.isInAnimationFrame = true; | |
| requestAnimationFrameFn(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ember/objectimports won’t resolve in the current ember-try scenarios that use bower Ember (e.g., 1.13). This will break those builds/tests unless the addon is migrated to ember-source + ember-modules. Also, the line has trailing whitespace which violates the repo’s.editorconfig(trim_trailing_whitespace = true).