ngMorph

  • 所有者: jimobrien/ngMorph
  • 平台:
  • 许可证: GNU General Public License v3.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

ngMorph Build Status

Morphable Elements

This module is an attempt at packaging transitions/animations into directives that enable the reuse of elements by morphing them into other elements. The idea was inspired by Google's Topeka project and a great concept I saw on Codrops. Simply create an originating element and apply the ng-morph-<type> directive to make it morphable. Check out the demo page to see it in action!

ngMorph Demo

Demo

Available here. Demo source available here.

Getting Started

  1. Install with bower:
```sh
  bower install --save angular-morph
```
  1. Include the module in your project:

      angular.module('yourApp', ['ngMorph']);
    

Usage

Morphables require a settings object which you define in your controller. Settings for each morphable can be found in their respective usage example below.

###Modal###

  <button ng-morph-modal="settings"> Log In </button>
  app.controller('AppCtrl', function ($scope) {
    $scope.settings = {
      closeEl: '.close',
      modal: {
        templateUrl: 'path/to/view.html',
        position: {
         top: '30%',
         left: '20%'
        },
        fade: false
      }
    }
  });

Modal Settings

  • closeEl: A class/id selector that will close the modal when clicked.
  • modal: Required. The modal configuration object.
  • templateUrl: Required if template is not defined. The path to the view template.
  • template: Required if templateUrl is not defined. An HTML template string. If templateUrl is also defined, template will take priority.
  • position: Optional. The positioning of the end-state element. Can either be pixels or a percentage. If no unit is specified, the input will be treated as a percentage ("30" => "30%").
  • fade: Optional. Fade the background content when the modal is open. Default is true.

###Overlay###

  <div ng-morph-overlay="settings"> ... </div>
  app.controller('AppCtrl', function ($scope) {
    $scope.settings = {
      closeEl: '.close',
      overlay: {
        templateUrl: 'path/to/view.html',
        scroll: false
      }
    }
  });

Overlay Settings

  • closeEl: A class/id selector that will close the overlay when clicked.
  • overlay: Required. The overlay configuration object.
  • scroll: Optional. Disable scrolling when overlay is active. Default is true.
  • templateUrl: Required if template is not defined. The path to the view template.
  • template: Required if templateUrl is not defined. An HTML template string. If templateUrl is also defined, template will take priority.

###Expand (Coming Soon!)###

  <div ng-morph-expand="settings"> ... </div>
  app.controller('AppCtrl', function ($scope) {
    $scope.settings = {
      closeEl: '.close',
      expand: {
        templateUrl: 'path/to/view.html'
      }
    }
  });

###Views###
In order for elements to morph into their end-state view properly, the contents that make up the view need to be wrapped in a single containing element. Here's an example of what a proper view looks like:

  <div class="col-md-12 login"> <!-- the containing element -->
  
    <!-- contents that make up the view start here -->
    <div class="row">
      <span class="glyphicon glyphicon-remove close-x pull-right"></span>
    </div>
    <div class="row">
      <form>
        <p><label>Email</label><input type="text" /></p>
        <p><label>Password</label><input type="password" /></p>
        <p><button>Login</button></p>
      </form>
    </div>
    
  </div> <!-- /end containing element -->

Contributing

What's Next

There is a lot of work to do before this is ready for an alpha release.. Following is a list of todos to get this repo in shape:

  • Abstract functionality from the post-linking function of the morphable directive.
  • Refactor using ngAnimate and GSAP (sticking with CSS transitions)
  • Add support for nested morphables (morphables within view templates)
  • Add different transitions (modal, screen overlay, expand (left, right, down, up))
  • Add before/after animation hooks.. (or broadcast events?)
  • Validate input settings
  • Add error handling
  • Write tests
  • Write docs
  • convert these items into GH issues

主要指标

概览
名称与所有者jimobrien/ngMorph
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证GNU General Public License v3.0
所有者活动
创建于2014-08-27 04:39:47
推送于2019-07-03 17:32:10
最后一次提交2014-09-22 10:22:48
发布数2
最新版本名称v0.1.0 (发布于 )
第一版名称v0.0.1 (发布于 )
用户参与
星数593
关注者数19
派生数36
提交数162
已启用问题?
问题数15
打开的问题数6
拉请求数2
打开的拉请求数3
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?