Created
March 11, 2017 19:39
-
-
Save AdreeUA/5f788e28dc05106b4f6e0704a2885e4c to your computer and use it in GitHub Desktop.
Modal animation exploration
This file contains hidden or 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
| <div class="demo-only" style="height:640px;"> | |
| <div id="dialog" role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open"> | |
| <div class="slds-modal__container"> | |
| <div class="slds-modal__header"> | |
| <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close"> | |
| <svg id="close" class="slds-button__icon slds-button__icon--large" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="52" height="52" viewBox="0 0 52 52"> | |
| <g stroke-width="6" stroke="#fff"> | |
| <line x1="26" x2="4" y1="26" y2="4" /> | |
| <line x1="26" x2="48" y2="4" y1="26" /> | |
| <line x1="26" x2="2" y1="26" y2="48" /> | |
| <line x1="26" x2="48" y1="26" y2="48" /> | |
| </g> | |
| </svg> | |
| <span class="slds-assistive-text">Close</span> | |
| </button> | |
| <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2> | |
| </div> | |
| <div class="slds-modal__content slds-p-around--medium"> | |
| <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore | |
| quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p> | |
| <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt nostrud | |
| ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p> | |
| </div> | |
| <div class="slds-modal__footer"> | |
| <button class="slds-button slds-button--neutral">Cancel</button> | |
| <button class="slds-button slds-button--brand">Save</button> | |
| </div> | |
| </div> | |
| </div> | |
| <button id="trigger" class="slds-button slds-button--brand">Trigger modal</button> | |
| <div class="slds-backdrop slds-backdrop--open"></div> | |
| </div> |
This file contains hidden or 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
| var $close = $('#close'); | |
| var $dialog = $('.slds-modal__content'); | |
| MorphSVGPlugin.convertToPath() | |
| function revolve() { | |
| var tl = new TimelineMax(); | |
| return tl.add("begin") | |
| .to($('#close'), .3, { | |
| scale: 1.5, | |
| ease: Expo.easeInOut | |
| }) | |
| .to($('#close line'), .3, { | |
| drawSVG: 0, | |
| ease: Expo.easeInOut | |
| }, "begin+=0.2") | |
| .add("closed") | |
| .to($dialog, .5, { | |
| height: 0, | |
| padding: 0, | |
| ease: Expo.easeInOut | |
| }) | |
| .to($('#dialog'), .4, { | |
| y: '-100%', | |
| ease: Expo.easeInOut | |
| }) | |
| .to($('.slds-backdrop'), .4, { | |
| ease: Expo.easeInOut, | |
| autoAlpha: 0 | |
| }, "closed+=0.6") | |
| } | |
| var closeAnimation = new TimelineMax({ | |
| paused: true | |
| }); | |
| closeAnimation.add(revolve()); | |
| $close.on("click", function(e) { | |
| e.preventDefault(); | |
| closeAnimation.restart(); | |
| }); | |
| $('#trigger').on("click", function(e) { | |
| e.preventDefault(); | |
| closeAnimation.reverse(); | |
| }); |
This file contains hidden or 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
| <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
| <script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js"></script> | |
| <script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/16327/DrawSVGPlugin.min.js"></script> | |
| <script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/16327/MorphSVGPlugin.min.js?r=18"></script> |
This file contains hidden or 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
| .slds-button:focus { | |
| box-shadow: none !important; // Don't do that in production | |
| } |
This file contains hidden or 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
| <link href="https://unpkg.com/@salesforce-ux/design-system@2.2.1/assets/styles/salesforce-lightning-design-system.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment