GithubHelp home page GithubHelp logo

Comments (5)

alepee avatar alepee commented on May 27, 2024

I finally did it without ngAnimate service.

ModalController

myApp.controller 'ModalConfirmController', ($scope, $timeout, $element, inputs, close) ->

  angular.extend $scope, inputs

  $scope.id ?= 'modal-default'
  $scope.backdrop ?= true
  $scope.display = true

  # remove class `modal-animate-enter` after modal render
  # (I am still looking for a way to do it with something like `Modal.open().then`)
  $timeout ->
    $element.removeClass 'modal-animate-enter'
  , 300

  $scope.close = (result) ->
    $element.addClass 'modal-animate-leave'
    $timeout ->
      $scope.display = false
      close result
    , 500

Template

.modal.modal-confirm.modal-animate-enter ng-show="display" ng-class="id"
  .modal-backdrop ng-if="backdrop" ng-click="close(false)"
  .modal-dialog
    .modal-image ng-if="imageUrl": img ng-src="imageUrl"
    .modal-title ng-if="title" ng-bind="title"
    .modal-content ng-bind-html="content"
    .modal-footer
      button ng-click="close(false)" ng-bind="cancel.text" ng-class="cancel.class"
      button ng-click="close(true)" ng-bind="confirm.text" ng-class="confirm.class"

Stylesheet

.modal
{
    position: fixed;
    z-index: 999;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    height: 100%;
    .modal-backdrop
    {
        position: absolute;

        width: 100%;
        height: 100%;

        transition: opacity 280ms linear;

        opacity: 1;
        background-color: rgba(0,0,0,0.3);
    }
    .modal-dialog
    {
        position: relative;
        top: 20%;

        width: 650px;
        max-width: 100%;
        margin: 0 auto;

        transition-duration: 500ms;
        transition-property: transform, opacity;
        transform: translateY(0);

        opacity: 1;
        border-radius: 10px;
        background-color: $white;
        box-shadow: 7px 13px 30px 0.00px rgba(75, 97, 109, 0.3);

        transform-style: preserve-3d;
    }
    &.modal-animate-enter
    {
        .modal-dialog
        {
            transition-timing-function: cubic-bezier(0.4, 0, 0, 1.5);
            transform: translateY(-200px);
        }
    }
    &.modal-animate-leave
    {
        .modal-dialog
        {
            transition-timing-function: cubic-bezier(1.5,0,0,0.4);
            transform: translateY(200px);
        }
    }
    &.modal-animate-enter,
    &.modal-animate-leave
    {
        .modal-dialog,
        .modal-backdrop
        {
            opacity: 0;
        }
    }
}

from angular-modal-service.

dwmkerr avatar dwmkerr commented on May 27, 2024

Thanks for sharing your code, I'll leave this issue open for now so others can find it easily.

from angular-modal-service.

LunarDevelopment avatar LunarDevelopment commented on May 27, 2024

It'd be nice to have a version of this code written in standard typing, I'm assuming this is typescript or coffee script or some extended syntax I'm not familiar with.. :<

from angular-modal-service.

alepee avatar alepee commented on May 27, 2024

@LunarDevelopment yes javascript is written in coffee, css in sass and html with slim.
Here is the javascript part, compiled by js2.coffee

ModalController

  myApp.controller('ModalConfirmController', function($scope, $timeout, $element, inputs, close) {
    angular.extend($scope, inputs);
    if ($scope.id == null) {
      $scope.id = 'modal-default';
    }
    if ($scope.backdrop == null) {
      $scope.backdrop = true;
    }
    $scope.display = true;
    $timeout(function() {
      return $element.removeClass('modal-animate-enter');
    }, 300);
    return $scope.close = function(result) {
      $element.addClass('modal-animate-leave');
      return $timeout(function() {
        $scope.display = false;
        return close(result);
      }, 500);
    };
  });

from angular-modal-service.

dwmkerr avatar dwmkerr commented on May 27, 2024

#93 now holds context on this ongoing issue, please move conversations to that thread!

from angular-modal-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.