-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Dialog API buff-up. #325
Merged
miguelcobain
merged 4 commits into
adopted-ember-addons:wip/v1.0.0
from
DanChadwick:dialog-buffup
Mar 28, 2016
Merged
Dialog API buff-up. #325
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eaf0b2f
Dialog API buff-up. parent, origin, openFrom, closeTo are all optiona…
DanChadwick 8bdf1e6
Protect open translate end handler from being called if component has…
DanChadwick e53e930
Reorder documentation slightly.
DanChadwick 5e72f33
ember-paper: Improved applied id for dialog parent.
DanChadwick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,28 +6,26 @@ const { | |
String: { htmlSafe }, | ||
RSVP: { Promise }, | ||
computed, | ||
on, | ||
inject: { service }, | ||
run, | ||
K | ||
K, | ||
typeOf | ||
} = Ember; | ||
|
||
export function toJQuery(element) { | ||
return typeOf(element) === 'string' ? $(element) : element; | ||
} | ||
|
||
export default Mixin.create({ | ||
constants: service(), | ||
|
||
attributeBindings: ['translateStyle:style'], | ||
classNameBindings: ['transformIn:md-transition-in'], | ||
|
||
fromElement: computed.or('openFrom', 'origin'), | ||
|
||
toElement: computed.or('closeTo', 'origin'), | ||
|
||
fromStyle: computed('fromElement', function() { | ||
return this.toTransformCss(this.calculateZoomToOrigin(this.element, this.get('fromElement'))); | ||
fromStyle: computed('defaultedOpenFrom', function() { | ||
return this.toTransformCss(this.calculateZoomToOrigin(this.element, this.get('defaultedOpenFrom'))); | ||
}), | ||
|
||
translateToParent: computed.or('closeTo', 'origin', 'parent', 'defaultParent'), | ||
|
||
centerStyle: computed(function() { | ||
return this.toTransformCss(''); | ||
}), | ||
|
@@ -59,8 +57,10 @@ export default Mixin.create({ | |
// Wait while CSS takes affect | ||
// Set the `main` styles and run the transition-in styles | ||
run.next(() => { | ||
this.waitTransitionEnd(this.element).then(() => { | ||
this.onTranslateFromEnd(); | ||
this.waitTransitionEnd($(this.element)).then(() => { | ||
if (!this.get('isDestroying') && !this.get('isDestroyed')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason for this guard? |
||
this.onTranslateFromEnd(); | ||
} | ||
}); | ||
this.set('transformStyleApply', 'main'); | ||
this.set('transformIn', true); | ||
|
@@ -79,21 +79,18 @@ export default Mixin.create({ | |
let containerClone = this.$().parent().clone(); | ||
let dialogClone = containerClone.find('md-dialog'); | ||
|
||
let toElement = this.get('toElement'); | ||
let toStyle = this.toTransformCss(this.calculateZoomToOrigin(this.element, toElement)); | ||
|
||
let origin = this.get('origin'); | ||
let toStyle = this.toTransformCss(this.calculateZoomToOrigin(this.element, this.get('defaultedCloseTo'))); | ||
|
||
run.schedule('afterRender', () => { | ||
$(this.get('parentElement')).parent().append(containerClone); | ||
toJQuery(this.get('defaultedParent')).parent().append(containerClone); | ||
run.next(() => { | ||
dialogClone.removeClass('md-transition-in'); | ||
dialogClone.addClass('md-transition-out'); | ||
dialogClone.attr('style', toStyle); | ||
run.next(() => { | ||
this.waitTransitionEnd(dialogClone).then(() => { | ||
containerClone.remove(); | ||
this.onTranslateToEnd(origin); | ||
this.onTranslateToEnd(toJQuery(this.get('origin'))); | ||
}); | ||
}); | ||
}); | ||
|
@@ -107,14 +104,14 @@ export default Mixin.create({ | |
* | ||
* @public | ||
*/ | ||
waitTransitionEnd(element) { | ||
waitTransitionEnd($element) { | ||
|
||
// fallback is 3 secs | ||
return new Promise((resolve/*, reject*/) => { | ||
|
||
// Upon timeout or transitionEnd, reject or resolve (respectively) this promise. | ||
// NOTE: Make sure this transitionEnd didn't bubble up from a child | ||
$(element).on(this.TRANSITIONEND, function(ev) { | ||
$element.on(this.TRANSITIONEND, function(ev) { | ||
if (ev) { | ||
resolve(); | ||
} | ||
|
@@ -138,7 +135,7 @@ export default Mixin.create({ | |
let zoomStyle; | ||
|
||
if (originator) { | ||
originator = typeof originator === 'string' ? $(originator).get(0) : originator; | ||
originator = toJQuery(originator).get(0); | ||
let originBnds = this.copyRect(originator.getBoundingClientRect()); | ||
let dialogRect = this.copyRect(element.getBoundingClientRect()); | ||
let dialogCenterPt = this.centerPointFor(dialogRect); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why this change?
defaultedParent
is the newparentElementSelector
?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.
+1,parentElement
||parentElementSelector
is a very clear descriptor.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.
I'm not complaining about the names. Just trying to understand.