button noslowanimations设置什么意思

Animations - Archived Tutorial - Dojo Toolkit
This tutorial is for Dojo 1.6 and may be out of date.
are available.
Animations
In this tutorial, you will learn how to use Dojo to create and combine effects for customized animation of elements on the page.
Final Product What you'll be creating
Getting Started
Web UIs, like all graphical user interfaces, need to maintain the illusion that all these pixels and buttons are connected to real things we can manipulate. Our brains can suspend disbelief and function efficiently with digital, virtual experiences as long as that illusion exists. The illusion can break down when transitions between changes are abrupt. Animating transitions helps UI to feel more natural and intuitive and can be used to subtly or not so subtly draw attention to changes on the page.
Or, to put it another way: you need more cowbell!
In this tutorial we'll learn more about the animation tools Dojo provides, to allow you to tweak and build custom animations to fit your specific UI requirements.
Effects Recap
We've discussed some of the built-in, commonly used
in a previous tutorial. We can fade elements with dojo.fadeIn and dojo.fadeOut, and we've got dojo.fx.slideTo and dojo.fx.wipeIn not far away in the dojo.fx module. We've already seen how you can pass a parameter object to these functions, with a node property to indicate what we want to animate:
dojo.fx.wipeIn({
node: wipeTarget
}).play();
But elements have countless properties with unit values that we could potentially animate. Suppose we wanted to flash the background, or move the node around on the screen? For that we need Dojo's generic animation utility, dojo.animateProperty.
Animating Properties
If you were to look at the source code to dojo.fx.wipeIn, you would see that basically the style.height property of the node is being changed from 0 to its auto or natural height.
To see how we can create animations of arbitrary properties, we're going to animate the border of a node.
Here's the markup we'll be working with:
&button id=&startButton&&Grow Borders&/button&
&button id=&reverseButton&&Shrink Borders&/button&
&div id=&anim8target& class=&box& style=&border-style:outset&&
&div class=&innerBox&&A box&/div&
The animateProperty method follows the same pattern we've used already. It's specifically the border-width property we want to animate, so our call to animateProperty looks like this
dojo.animateProperty({
node: dojo.byId(&anim8target&),
properties: { borderWidth: 100 }
}).play();
Notice that we use the JavaScript "humpback" property name borderWidth, not the hyphenated CSS border-width property name. We're still passing in a node property, but this time we're using a new 'properties' key to specify what it is we want to animate.
That same principal works for all properties that can have numeric values, and we can specify as many as we like.
In this example, we'll animate top, left and opacity at the same time, to have the element drop out and fade away to the left. By providing specific start and end properties for each, we can make very specific, repeatable animations.
dojo.animateProperty({
node: anim8target,
properties: {
top: : { start: 25, end: 150 },
opacity: { start: 1, end: 0 }
duration: 800
}).play();
Notice that we've also provided a duration property. This is the number of milliseconds the whole animation should take, and in this case it gives us a bit more time to see what's going on.
If we were to plot the values our animation generates, we would see a curve from the start value to the end value over time. The shape of this curve is referred to as "easing".
The most simple "curve" is a straight line - the node, for example, moves at an even speed from x:0 to y:100. But movements look more natural when they start slow, speed up and then slow down again right at the end.
The default works in most places, but Dojo provides a wide range of easing functions to get the right effect and feel. The dojo.fx.easing module has several easing curves we can load:
dojo.require(&dojo.fx&);
// To use the alternate easing methods,
// we need to require the dojo.fx.easing module
dojo.require(&dojo.fx.easing&);
// dojo.window provides convenient and cross-browser viewport measurements
dojo.require(&dojo.window&);
dojo.ready(function(){
var dropButton = dojo.byId("dropButton"),
ariseSirButton = dojo.byId("ariseSirButton"),
anim8target = dojo.byId("anim8target");
// Set up a couple of click handlers to run our animations
dojo.connect(dropButton, "onclick", function(evt){
// get the dimensions of our viewport
var viewport = dojo.window.getBox(dojo.doc);
dojo.animateProperty({
// use the bounceOut easing routine to have the box accelerate
// and then bounce back a little before stopping
easing: dojo.fx.easing.bounceOut,
duration: 500,
node: anim8target,
properties: {
// calculate the 'floor'
// and subtract the height of the node to get the distance from top we need
top: { start: 0, end:viewport.h - anim8target.offsetHeight }
}).play();
In this example, we're calculating the viewport height so we can position the box to appear to sit at the bottom. By using the bounceOut easing function, it reaches the value for that floor, then winds it back up a bit, before settling back to the final value.
Notice also that the top property is an object with start and end properties, which lets us be very specific about the range of values we want to animate over for each style property.
Almost all of the easings have names that end in either "In" or "Out" & or both, as "InOut". The name implies whether the easing is going to affect the beginning (In), ending (Out), or both ends (InOut) of the animation. Be sure to check out
for more detail.
Putting it Together
Traditional animation software typically uses a timeline to model what is changing over what period, and it's normal to have things moving simultaneously, as well as one after the other.
As we've seen in the earlier Effects tutorial, Dojo provides a mechanism for each: bine and dojo.fx.chain. Let's see how to put the pieces together.
For this demo, the setup is that we have two boxes of content which we want to swap. To highlight the change we'll also fade out the background color behind them.
Here's the markup we'll be working with:
&button id=&swapButton&&Swap&/button&
&div class=&container& id=&container&&
&div id=&content1& class=&contentBox& style=&top: 0; left: 0&&
&div class=&innerBox&&1: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.&/div&
&div id=&content2& class=&contentBox& style=&top: 0; left: 250px&&
&div class=&innerBox&&2: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&/div&
As usual, we load Dojo, and do our initialization inside a function we pass to dojo.ready.
&script src=&///ajax/libs/dojo/1.6.3/dojo/dojo.xd.js&&&/script&
dojo.require(&dojo.fx&);
function swapAnim(node1, node2) {
// create & return animation which swaps the positions of 2 nodes
// Once our modules have loaded and the DOM is ready...
dojo.ready(function(){
var originalOrder = // track which order our content nodes are in
var swapButton = dojo.byId(&swapButton&),
c1 = originalOrder ? dojo.byId(&content1&) : dojo.byId(&content2&),
c2 = originalOrder ? dojo.byId(&content2&) : dojo.byId(&content1&),
container = dojo.byId(&container&);
// Set up a click handler to run our animations
dojo.connect(swapButton, &onclick&, function(evt){
// pass the content nodes into swapAnim to create the node-swapping effect
// and chain it with a background-color fade on the container
// ensure the originalOrder bool gets togged properly for next time
Being able to compose complex animations from distinct pieces is immensely useful. We've broken the animation out into separate pieces here, so we can keep the position-swapping code generic and reusable.
The implementation for the swapAnim function looks like this:
function swapAnim(node1, node2) {
var posn1 = parseInt(dojo.style(node1, "left")),
posn2 = parseInt(dojo.style(node2, "left"));
return moveNodes = bine([
dojo.fx.slideTo({
node: node2,
left: posn1
dojo.fx.slideTo({
node: node1,
left: posn2
The slideTo method is used to actually move each node, using the left style property. We might also have used animateProperty to similar effect.
The two separate animations should run in parallel, so both nodes move at once. The bine method accomplishes that - making one animation from two.
Notice that we return the animation object just like animateProperty and the other Dojo methods do. It's up to the calling code to play() it when needed.
// Set up a click handlers to run our animations
dojo.connect(swapButton, "onclick", function(evt){
// chain the swap nodes animation
// with another to fade out a background color in our container
var anim = dojo.fx.chain([
swapAnim(c1, c2),
dojo.animateProperty({
node: container,
properties: {
backgroundColor: "#fff"
// before the animation begins, set initial container background
dojo.connect(anim, "beforeBegin", function(){
dojo.style(container, "backgroundColor", "#eee");
// when the animation ends, toggle the originalOrder
dojo.connect(anim, "onEnd", function(n1, n2){
originalOrder = !originalO
anim.play();
Here is that calling code - the click handler. As with bine before, the array passed to dojo.fx.chain has two separate animations. However, we want to run these in series: the node-swap, then the background-color animation.
The container's initial background-color is set by connecting to the beforeBegin event, and during onEnd we have a little bookkeeping to do, to ensure that when we click next, the nodes are reversed.
The resulting code is flexible, logical and easily extended. What would you need to do to have the background animation run in parallel with the swap?
How about pushing back the opacity of the content as it moves to the right? As frequently happens, it turns out the hardest bit is knowing where to stop!
Conclusion
Dojo's animation utilities give you convenience and simplicity for the common cases, yet all the control you need for specific, custom transitions and other effects.
Animations can be built up from simple pieces and provide a useful set of lifecyle events to help synchronize changes.
In the real world, nothing snaps directly from one state to another, so the ability to control movement and visual change is important for creating great user experiences.
In future tutorials, we'll see the same pattern across the Dojo Toolkit: make the simple things easy, and the difficult things possible.Android浮动按纽:Floating Action Button library for Android
来源:open开发经验库
一个浮动按钮,拥有许多自定义的属性。浮动的操作按钮被用于一种特殊类型的促进作用。它们是由一个圆圈图标漂浮在UI上述区分,并有相关的变形,发射,并转印锚点特殊运动行为。//Button type
actionButton.setType(FloatingActionButton.Type.MINI);
//Button colors
actionButton.setButtonColor(getResources().getColor(R.color.fab_material_lime_500));
actionButton.setButtonColorPressed(getResources().getColor(R.color.fab_material_lime_900));
//Image
actionButton.setImageDrawable(getResources().getDrawable(R.drawable.fab_plus_icon));
actionButton.setImageSize(24.0f);
//Shadow
actionButton.setShadowColor(Color.parseColor("#757575"));
actionButton.setShadowRadius(1.0f);
actionButton.setShadowXOffset(0.5f);
actionButton.setShadowYOffset(1.0f);
//Stroke
actionButton.setStrokeColor(getResources().getColor(R.color.fab_material_blue_grey_500));
actionButton.setStrokeWidth(1.0f);
//Animations
actionButton.setAnimationOnShow(FloatingActionButton.Animations.ROLL_FROM_DOWN);
actionButton.setAnimationOnHide(FloatingActionButton.Animations.ROLL_TO_DOWN); Animations 
The Library has several predefined animations: 
Fade In - Fade Out 
Roll From Down - Roll To Down 
Jump From Down - Jump To Down 
项目主页:
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动欢迎来到js特效学院!
用于Button按钮的jQuery插件的应用教程
作者/来源:本站原创
jQuery已经被广泛的应用于网页制作当中,今天介绍给大家的主要集中在button按钮上面,一个优秀的按钮,动态效果或者一些Tip提示,或者一个图层透明度为50%,以及CSS3+jQuery效果等,都是一个很精典的设计,一起分享分
jQuery已经被广泛的应用于网页制作当中,今天介绍给大家的主要集中在button按钮上面,一个优秀的按钮,动态效果或者一些Tip提示,或者一个图层透明度为50%,以及CSS3+jQuery效果等,都是一个很精典的设计,一起分享分们吧。
How to create Skype-like buttons using jQuery
Creative Button Animations with Sprites and JQuery
Scalable css buttons using png and background colors
Simple Accordion w/ CSS and jQuery
Make Fancy Light Up RSS Button With JQuery Fading
Pretty checkboxes with jQuery
BubbleUp jQuery Plugin to Spice Up Your Menu
Create Twitter-Style Buttons with the Dojo Toolkit
Create a Realistic Hover Effect With jQuery
Nice And Simple Toolbar For Your Website With CSS3 And jQuery
jQuery Horizontal Tooltips Menu Tutorials
Query style menu with CSS3
本文地址:/html/webdesign/1738.htm
这些是大家喜欢的...
这些是最新的文章...代码片段之Masonry 按钮放大缩小动画简单实践 - 简书
下载简书移动应用
写了33659字,被44人关注,获得了48个喜欢
代码片段之Masonry 按钮放大缩小动画简单实践
// UIView如果使用AutoLayout 必须写此方法
+ (BOOL)requiresConstraintBasedLayout
return YES;
//按钮的动态效果修改时 此方法为 系统自带方法
// this is Apple's recommended place for adding/updating constraints
- (void)updateConstraints {
[self.growingButton updateConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.equalTo(@(self.buttonSize.width)).priorityLow();
make.height.equalTo(@(self.buttonSize.height)).priorityLow();
make.width.lessThanOrEqualTo(self); //按钮的最大宽度 &= 当前self的宽度
make.height.lessThanOrEqualTo(self); //按钮的最大高度 &= 当前self的宽度
//according to apple super should be called at end of method
[super updateConstraints]; //苹果规定最后调用这个
//按钮触发的时候
[self setNeedsUpdateConstraints]; //必须调用
[self updateConstraintsIfNeeded]; //更新约束
[UIView animateWithDuration:0.4 animations:^{
[self layoutIfNeeded];
//动画效果
//代码演示
- (void)didTapGrowButton:(UIButton *)button {
if (!self.zoom) {
self.buttonSize = CGSizeMake(self.buttonSize.width * 5, self.buttonSize.height * 6);
self.zoom = YES;
self.buttonSize = CGSizeMake(self.buttonSize.width / 5, self.buttonSize.height /
self.zoom = NO;
// tell constraints they need updating
[self setNeedsUpdateConstraints];
// update constraints now so we can animate the change
[self updateConstraintsIfNeeded];
[UIView animateWithDuration:0.4 animations:^{
[self layoutIfNeeded];
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
被以下专题收入,发现更多相似内容:
· 217人关注
点滴积累 弥足珍贵
· 121人关注
mansory与autolayout
· 21人关注
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
选择支付方式:

我要回帖

更多关于 richbutton是什么意思 的文章

 

随机推荐