Skip to content

Instantly share code, notes, and snippets.

@jacobq
Forked from Gaurav0/controllers.application.js
Last active December 15, 2020 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jacobq/ff9ff22445f6215d4f238f6c35e2d4bc to your computer and use it in GitHub Desktop.
Save jacobq/ff9ff22445f6215d4f238f6c35e2d4bc 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-dialog',
use: ['fade', options]
}, {
pick: '.ember-modal-overlay',
use: ['fade', options]
})
);
};
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
overlayPosition='sibling'
animatable=true
}}<p>Oh hai there!</p>
<a href="#" class="close-button" {{action 'toggle'}}>Close</a>
{{/modal-dialog}}
{{/liquid-if}}
<br>
Thanks <a href="https://github.com/yapplabs/ember-modal-dialog/issues/199#issuecomment-309583342">billdami</a> for suggesting: <pre>overlayPosition='sibling'</pre>
<!--
<br><br>
Working around problem using CSS to hide "ghost" modal:
<pre>
.ember-modal-overlay ~ .ember-modal-dialog {
display: none !important;
}
</pre>
-->
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"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