Skip to content

Instantly share code, notes, and snippets.

@billdami
Forked from jacobq/app.transitions.js
Created June 19, 2017 20:46
Show Gist options
  • Save billdami/a7cda36403475c9290738e4cfbbb08c4 to your computer and use it in GitHub Desktop.
Save billdami/a7cda36403475c9290738e4cfbbb08c4 to your computer and use it in GitHub Desktop.
Modal Dialog Test
// Problem happens regardless of duration, but unless using
// the `.velocity-animating` CSS hack it is easier to see with longer durations.
const options = {duration: 1000, easing: 'easeInOutQuad'};
export default function(){
this.transition(
// this works
//this.use('fade')
// this has a glitch; can see second copy/ghost of modal in top left when closing
this.use('explode', {
pick: '.ember-modal-overlay',
use: 'fade'
}, {
pick: '.ember-modal-dialog',
use: 'toUp'
})
);
};
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'ember-modal-dialog test',
show: false,
actions: {
toggle() {
this.toggleProperty('show');
}
}
});
/* Avoid scrollbars */
body {
margin: 0;
padding: 0;
border: 0;
}
/* Hack #1 -- almost does the trick but still flashes briefly */
.ember-modal-overlay.velocity-animating .ember-modal-dialog {
display: none !important;
}
/* Hack #2 -- works but quite fragile (depends on liquid-fire explode ordering, etc.) */
/*.ember-modal-overlay ~ .ember-modal-dialog {
display: none !important;
}*/
/* Taken from ember-modal-structure.scss, adapted for compatibility */
.ember-modal-dialog {
z-index: 51;
position: fixed;
}
.ember-modal-dialog.emd-in-place {
position: static;
}
.ember-modal-wrapper.emd-static.emd-wrapper-target-attachment-center .ember-modal-dialog {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.ember-modal-wrapper.emd-animatable.emd-wrapper-target-attachment-center {
width: 100%;
width: 100vw;
height: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 50;
display: flex;
align-items: center;
justify-content: center;
}
.ember-modal-wrapper.emd-animatable.emd-wrapper-target-attachment-center .ember-modal-overlay {
display: flex;
align-items: center;
justify-content: center;
}
.ember-modal-wrapper.emd-animatable .ember-modal-dialog {
position: relative;
}
.ember-modal-overlay {
width: 100%;
width: 100vw;
height: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 50;
}
/* Taken from ember-modal-appearance.scss and adapted for compatibility */
.ember-modal-dialog {
border-radius: 8px;
background-color: #fff;
box-shadow: 0 0 10px #222;
padding: 10px;
}
.ember-modal-overlay.translucent {
background-color: grey;
background-color: rgba(127, 127, 127, 0.77);
background-color: rgba(#808080, .77);
}
<h1>Welcome to {{appName}}</h1>
show: {{show}}<br>
<a href="#" {{action 'toggle'}}>Toggle</a>
{{#liquid-if show}}
{{#modal-dialog
onClose='toggle'
translucentOverlay=true
animatable=true
}}<p>Oh hai there!</p>
<a href="#" class="close-button" {{action 'toggle'}}>Close</a>
{{/modal-dialog}}
{{/liquid-if}}
<br><br>
Working around problem using CSS to hide "ghost" modal:
<pre>
.ember-modal-overlay ~ .ember-modal-dialog {
display: none !important;
}
</pre>
{
"version": "0.12.1",
"ENV": {
"ember-modal-dialog": {
"hasLiquidWormhole": "2.0.5",
"hasLiquidTether": "2.0.4",
"hasEmberTether": "1.0.0-beta.0"
}
},
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js",
"ember": "2.12.0",
"ember-modal-dialog": "2.2.0",
"ember-tether": "1.0.0-beta.0",
"liquid-fire": "0.27.3",
"liquid-tether": "2.0.4",
"liquid-wormhole": "2.0.5"
},
"addons": {
"liquid-fire": "0.27.3",
"liquid-tether": "2.0.4",
"liquid-wormhole": "2.0.5",
"ember-tether": "1.0.0-beta.0",
"ember-modal-dialog": "2.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment