#Fixed# easy-animation | Animation for Sass

原文链接:http://www.cnblogs.com/maplejan/p/3659830.html

主要修复3.4版本后变量作用域的问题。

代码如下:

  1 /* easy-animation.scss */
  2
  3
  4 // easy-animation
  5 // Author: Maple Jan
  6 // Date: 2016-10-21
  7
  8
  9 // Support browser‘s private prefix.
 10 $ea-prefix-for-webkit:       true !default;
 11 $ea-prefix-for-mozilla:      true !default;
 12 $ea-prefix-for-microsoft:    true !default;
 13 $ea-prefix-for-opera:        true !default;
 14 $ea-prefix-for-spec:         true !default; // required for keyframe mixin
 15
 16
 17 // Disable all browser‘s private prefix.
 18 @mixin ea-disable-prefix-for-all() {
 19   $ea-prefix-for-webkit:    false !global;
 20   $ea-prefix-for-mozilla:   false !global;
 21   $ea-prefix-for-microsoft: false !global;
 22   $ea-prefix-for-opera:     false !global;
 23   $ea-prefix-for-spec:      false !global;
 24 }
 25
 26
 27 // Example usage:
 28 // @include ea-transition(all 2s ease 0s);
 29 @mixin ea-transition($value, $prefixs: webkit moz ms o spec) {
 30   @each $prefix in $prefixs {
 31     @if $prefix == webkit {
 32       @if $ea-prefix-for-webkit {
 33         -webkit-transition: $value;
 34       }
 35     }
 36     @else if $prefix == moz {
 37       @if $ea-prefix-for-mozilla {
 38         -moz-transition: $value;
 39       }
 40     }
 41     @else if $prefix == ms {
 42       @if $ea-prefix-for-microsoft {
 43         -ms-transition: $value;
 44       }
 45     }
 46     @else if $prefix == o {
 47       @if $ea-prefix-for-opera {
 48         -o-transition: $value;
 49       }
 50     }
 51     @else if $prefix == spec {
 52       @if $ea-prefix-for-spec {
 53         transition: $value;
 54       }
 55     }
 56     @else  {
 57       @warn "Unrecognized prefix: #{$prefix}";
 58     }
 59   }
 60 }
 61
 62
 63 // Example usage:
 64 // @include ea-transform(scale(1));
 65 @mixin ea-transform($value, $prefixs: webkit moz ms o spec) {
 66   @each $prefix in $prefixs {
 67     @if $prefix == webkit {
 68       @if $ea-prefix-for-webkit {
 69         -webkit-transform: $value;
 70       }
 71     }
 72     @else if $prefix == moz {
 73       @if $ea-prefix-for-mozilla {
 74         -moz-transform: $value;
 75       }
 76     }
 77     @else if $prefix == ms {
 78       @if $ea-prefix-for-microsoft {
 79         -ms-transform: $value;
 80       }
 81     }
 82     @else if $prefix == o {
 83       @if $ea-prefix-for-opera {
 84         -o-transform: $value;
 85       }
 86     }
 87     @else if $prefix == spec {
 88       @if $ea-prefix-for-spec {
 89         transform: $value;
 90       }
 91     }
 92     @else  {
 93       @warn "Unrecognized prefix: #{$prefix}";
 94     }
 95   }
 96 }
 97
 98
 99 // Example usage:
100 // @include ea-animation(wrap_s0_p1, 2s, ease, 0s, infinite);
101 @mixin ea-animation($name, $duration, $function: ease, $delay: 0s, $count: infinite) {
102   -webkit-animation: $name $duration $function $delay $count;
103   -moz-animation: $name $duration $function $delay $count;
104   -ms-animation: $name $duration $function $delay $count;
105   -o-animation: $name $duration $function $delay $count;
106   animation: $name $duration $function $delay $count;
107 }
108
109
110 // Example usage:
111 // @include ea-keyframes(wrap_s0_p1) {
112 //   0% {
113 //     opacity: 1;
114 //     @include ea-transform(scale(1));
115 //   }
116 //   50% {
117 //     opacity: 0.8;
118 //     @include ea-transform(scale(0.8));
119 //   }
120 //   100% {
121 //     opacity: 1;
122 //     @include ea-transform(scale(1));
123 //   }
124 // }
125 @mixin ea-keyframes($name) {
126   $_ea-prefix-for-webkit:       $ea-prefix-for-webkit;
127   $_ea-prefix-for-mozilla:      $ea-prefix-for-mozilla;
128   $_ea-prefix-for-microsoft:    $ea-prefix-for-microsoft;
129   $_ea-prefix-for-opera:        $ea-prefix-for-opera;
130   $_ea-prefix-for-spec:         $ea-prefix-for-spec;
131
132
133   @if $_ea-prefix-for-webkit {
134     @include ea-disable-prefix-for-all();
135     $ea-prefix-for-webkit: true !global;
136     @-webkit-keyframes #{$name} {
137       @content;
138     }
139   }
140   @if $_ea-prefix-for-mozilla {
141     @include ea-disable-prefix-for-all();
142     $ea-prefix-for-mozilla: true !global;
143     @-moz-keyframes #{$name} {
144       @content;
145     }
146   }
147   @if $_ea-prefix-for-microsoft {
148     @include ea-disable-prefix-for-all();
149     $ea-prefix-for-microsoft: true !global;
150     @-ms-keyframes #{$name} {
151       @content;
152     }
153   }
154   @if $_ea-prefix-for-opera {
155     @include ea-disable-prefix-for-all();
156     $ea-prefix-for-opera: true !global;
157     @-o-keyframes #{$name} {
158       @content;
159     }
160   }
161   @if $_ea-prefix-for-spec {
162     @include ea-disable-prefix-for-all();
163     $ea-prefix-for-spec: true !global;
164     @keyframes #{$name} {
165       @content;
166     }
167   }
168
169
170   $ea-prefix-for-webkit:    $_ea-prefix-for-webkit !global;
171   $ea-prefix-for-mozilla:   $_ea-prefix-for-mozilla !global;
172   $ea-prefix-for-microsoft: $_ea-prefix-for-microsoft !global;
173   $ea-prefix-for-opera:     $_ea-prefix-for-opera !global;
174   $ea-prefix-for-spec:      $_ea-prefix-for-spec !global;
175 }
时间: 2024-08-07 21:16:39

#Fixed# easy-animation | Animation for Sass的相关文章

[ css 动画 animation ] animation新增动画属性的实例演示

<!DOCTYPE html> <html lang='zh-cn'> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>[ animation ] 新增动画属性的实例演示</title> <meta http-equiv='description' content='this

多余的MeshCollider和Animation

如果你是在做手游项目,我强烈建立不要做碰撞,有关一切物理的东西unity对手机支持的并不好,如果不信你可以试试效率你就知道.美术兄弟,每次给过来的场景,都会带上MeshCollider 和Animation 空的组件.这俩东西很占效率的,不信你可以用Profiler 看看.如果你让美工们上传场景的时候手动检查一下,把MeshCollider和Animation空的组件都删掉,我可以很负责的告诉你,他们肯定会忘删除或者错删...比如下图这样的组件. <ignore_js_op> 还有场景的材质最

Android Animation动画详解(二): 组合动画特效

前言 上一篇博客Android Animation动画详解(一): 补间动画 我已经为大家介绍了Android补间动画的四种形式,相信读过该博客的兄弟们一起都了解了.如果你还不了解,那点链接过去研读一番,然后再过来跟着我一起学习如何把简单的动画效果组合在一起,做出比较酷炫的动画特效吧. 一. 动画的续播 如题,大家想想,如果一个页面上包含了许多动画,这些动画要求按顺序播放,即一个动画播放完成后,继续播放另一个动画,使得这些动画具有连贯性.那该如何实现呢? 有开发经验或者是逻辑思维的人肯定会想,对

Android动画之二:View Animation

作为一个博客<Android其中的动画:Drawable Animation>.android动画主要分为三大部分.上一篇博客已经解说Drawable Animation的使用方法,即逐帧地显示图片,常常运用于动态显示一个进度动画,这是出现频率最高的应用场景.接下来.我们这篇文章将循序渐进.介绍View Animation. View Animation也是我们平时非常多书籍所说的Tweened Animation(有人翻译为补间动画).View Animation分为4大类:AlphaAni

Animation & Spritesheets

A sprite is a single graphic image. It can be moved around the screen, stretched, rotated, skewed, faded and tinted. A spritesheet is a collection of sprites into a single texture file. This makes it easy to animate a single sprite by changing the sp

CSS3新特性+less实验——animation

自从CSS3推出animation以来,一大批H5应用纷纷利用animation来制作以往需要JS或FLASH才能制作出的特效.今天就来看看animation的庐山真面目吧. 实验对象:animation animation可以被用来定义一组动画效果,此效果可以被应用在任何元素之上,并且可以通过它提供的各项参数精确控制动画的细节. 语法 animation:[[ animation-name ] || [ animation-duration ] || [ animation-timing-fu

Android动画介绍-Tween Animation

3.0以前,android支持两种动画模式,Tween Animation,Frame Animation 在android3.0中又引入了一个新的动画系统:Property Animation 这三种动画模式在SDK中被称为Property Animation,View Animation,Drawable Animation 下面介绍:Tween Animation View Animation(Tween Animation):补间动画,给出两个关键帧,通过一些算法将给定属性值在给定的时间

No shutdown animation in the electricity display only 1%

低电量自动关机时无关机动画 低电量自动关机时无关机动画1. 问题描述2. 分析3. solution4. 总结 1. 问题描述 DEFECT DESCRIPTION: No shutdown animation in the electricity display only 1%. REPRODUCING PROCEDURES: 电量消耗显示只有1%时,手机突然黑屏关机,没有关机动画,长按power键后手机又可以正常开机使用.(黑屏关机后插上充电器,电量显示为1%) EXPECTED BEHAV

android通过xml文件实现Animation动画

Rotate的xml文件编写方法 <rotate android:fromDegrees="0" android:toDegrees="+350" android:pivotX="50%" android:pivotY="50%" android:duration="1000"/> *android:toDegrees="+350"正号代表的是旋转方向,正号为顺时针,负号为逆

Android(五)动画Animation

第一种:代码格式: package com.itzb.annimation; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AlphaAnimation; import android.v