Nutt可重用的动态自定义页面过渡与javascript挂钩?

我有一个Nuxt.js网站,我正在尝试进行一些精美的页面转换。我想我了解仅在CSS上应该如何使用transition设置,但是如何使它与JavaScript挂钩可重用?

在我看来,我们应该能够执行以下操作:

// In a Page.vue template 
    transition(to,from) {
        if (!from) {
            return "fade"
        }
        if (to.name == "directors-name-work") {
            // Animate to video playing
            return "to-video"
        }
        if (from.name == "directors-name-work") {
            // Scroll to slideshow,and at same video we just came from.
            return "from-video"
        }
    }

然后,我需要能够在某个地方的JavaScript中定义to-videofrom-video的JS钩子,但我不知道该去哪儿?对于单独的过渡,enter()beforeEnter()挂钩在哪里定义?如果我们只有一个过渡,那是有道理的,那么我可以在mixin中完成。但是当它是动态的时,我不知道。

我是否应该将一个文件放在transition-to-videotransition-from-video某个地方?

tiankongxiangyun 回答:Nutt可重用的动态自定义页面过渡与javascript挂钩?

当前未公开,但页面的transition function可以返回transition object,其中可能包含transition JavaScript hooks。这样,您就可以在一个通用文件中定义共享的过渡对象,并根据需要将它们导入到页面中:

〜/ transitions.js:

package classes;


import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.PrimeFaces;
import org.apache.commons.beanutils.PropertyUtils;

/*
 * To change this license header,choose License Headers in Project Properties.
 * To change this template file,choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */

@ManagedBean(name="test")
@SessionScoped

public class Test implements Serializable {
    public String id;
    public String title;

    public Test() {
        id="1";
        title="Testing";
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void onRowSelect(int row) {
        try {
            System.out.println("Start:");
            String i="ID";
            String t="Title";
            String ci="id";
            String ct="title";
            this.getClass().getDeclaredField(ci).set(this,LiveRangeService.filteredData.get(row).get(i));
            this.getClass().getDeclaredField(ct).set(this,LiveRangeService.filteredData.get(row).get(t));
            PrimeFaces.current().ajax().update("form:inp");
            PrimeFaces.current().ajax().update("form:inp1");
            PrimeFaces.current().executeScript("PF('dlg').hide();");            
            System.out.println("End:");
        } catch (Exception e) {
            System.out.println("Error! " + e.getMessage() );
        }
    }
}

〜/ pages / about.vue:

export default {
  fade: {
    name: 'fade',mode: 'out-in',beforeEnter(el) {
      console.log('fade beforeEnter')
    }
  },bounce: {
    name: 'bounce',afterEnter(el) {
      console.log('bounce afterEnter')
    }
  },}
本文链接:https://www.f2er.com/3069133.html

大家都在问