gpt4 book ai didi

famo.us:结合 2 个转换同时运行

转载 作者:行者123 更新时间:2023-12-02 13:39:57 25 4
gpt4 key购买 nike

当用户第一次访问我的应用程序时,我有一个 Logo ,我想将其从屏幕中心移动到顶部,但随着它的移动,我也希望它缩小到原始大小的 1/2。可以通过famo.us 做到这一点吗?

最佳答案

有几种方法可以实现这一目标。为了清晰和简单起见,我建议使用 ModifierChain 类。这允许您将影响单个可渲染的修改器链接在一起。这是您想要实现的目标的示例。

祝你好运!

var Engine              = require("famous/core/Engine");
var Surface = require("famous/core/Surface");
var StateModifier = require("famous/modifiers/StateModifier");
var Transform = require("famous/core/Transform");
var ModifierChain = require("famous/modifiers/ModifierChain");
var Easing = require("famous/transitions/Easing");

var context = Engine.createContext();

var surface = new Surface({
size:[200,200],
properties: { backgroundColor: 'green'}
})

surface.chain = new ModifierChain();

surface.state = new StateModifier({ origin:[0.5,0.5] });
surface.sizeState = new StateModifier();

surface.chain.addModifier(surface.sizeState);
surface.chain.addModifier(surface.state);

context.add(surface.chain).add(surface);

surface.on('click', function(){

transition = {duration:1000,curve:Easing.inOutQuad};

surface.sizeState.setTransform(Transform.scale(0.5,0.5,1),transition);
surface.state.setOrigin([0.5,0],transition);

});

关于famo.us:结合 2 个转换同时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23485299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com