2015-07-01 3 views
0

Мои index.js выглядит такUncaught TypeError: this._queue [1] не является функцией

'use strict'; 

// Famous dependencies 
var DOMElement = require('famous/dom-renderables/DOMElement'); 
var FamousEngine = require('famous/core/FamousEngine'); 
var CustomNode = require('./CustomNode'); 
var Animation = require('./components/Animation'); 
// Boilerplate code to make your life easier 
FamousEngine.init(); 

var scene = FamousEngine.createScene('body'); 
var rootNode = scene.addChild(); 

var plane = rootNode.addChild(new CustomNode('url(images/plane_100x100.png)', '#B3E5FC', 200, 200, 100, 100)); 
var animation = new Animation(plane); 
animation.start(); 

где CustomNode.js является

var DOMElement = require('famous/dom-renderables/DOMElement'); 
var FamousEngine = require('famous/core/FamousEngine'); 
var Transitionable = require('famous/transitions/Transitionable'); 
var Size = require('famous/components/Size'); 
var Node = require('famous/core/Node'); 
function CustomNode(bgUrl, bgColor, xpos, ypos, width, height) { 
    Node.call(this); 
    this.setSizeMode('absolute', 'absolute') 
      .setAbsoluteSize(width, height) 
      .setPosition(xpos,ypos); 
    this.nodeDomElement = new DOMElement(this); 
    this.nodeDomElement.setProperty('backgroundImage', bgUrl); 
    this.nodeDomElement.setProperty('zIndex', '2'); 
    this.nodeDomElement.setProperty('background-color', bgColor); 
} 
CustomNode.prototype = Object.create(Node.prototype); 
CustomNode.prototype.constructor = CustomNode; 
module.exports = CustomNode; 

И Animation.js выглядит следующим образом

var FamousEngine = require('famous/core/FamousEngine'); 
var Transitionable = require('famous/transitions/Transitionable'); 

// A component that will animate a node's position in x. 
function Animation (node) { 
    // store a reference to the node 
    this.node = node; 
    // get an id from the node so that we can update 
    this.id = node.addComponent(this); 
    // create a new transitionable to drive the animation 
    this.xPosition = new Transitionable(100); 
} 

Animation.prototype.start = function start() { 
    // request an update to start the animation 
    this.node.requestUpdate(this.id); 
    // begin driving the animation 
    this.xPosition.from(100).to(1000, {duration: 1000}); 
    this.node.requestUpdate(this.id); 
}; 

Animation.prototype.onUpdate = function onUpdate() { 
    // while the transitionable is still transitioning 
    // keep requesting updates 
    if (this.xPosition.isActive()) { 
     // set the position of the component's node 
     // every frame to the value of the transitionable 
     this.node.setPosition(this.xPosition.get()); 
     this.node.requestUpdateOnNextTick(this.id); 
    } 
}; 
module.exports = Animation; 

Но когда я бегу известный Дев, я получаю следующую ошибку

Uncaught TypeError: this._queue[1] is not a function 

Пожалуйста, обратите внимание, что я работаю прочь разработки филиала известного/двигателя

Этот код размещен на GitHub

https://github.com/codesdk/famous_engine_issue_debug_animation

для легкого клонирования

Пожалуйста, используйте инструкцию в README

+0

Что линия делает точку ошибки на? – phts

+0

Это то, что я получаю на консоли ... no src filename в ошибке Uncaught TypeError: this._queue [1] не является functionget @ bundle.js: 10794onUpdate @ bundle.js: 13621update @ bundle.js: 3521_update @ bundle.js: 2036step @ bundle.js: 2174handleFrame @ bundle.js: 2156handleMessage @ bundle.js: 2107_channel.onMessage @ bundle.js: 1957postMessage @ bundle.js: 1125update @ bundle.js: 10109step @ bundle.js: 9060loop @ bundle.js: 9076_looper @ bundle.js: 8889 –

+0

Можете ли вы опубликовать свой проект в GitHub, чтобы мы могли создать весь проект и запустить его? – trusktr

ответ

2

Обязательно передайте правильные аргументы в Transitionable # to:

this.xPosition.from(100).to(1000, 'linear', 1000); 
1

Вы, возможно, перепутал set и to методы Transitionable.

this.xPosition.from(100).to(1000, {duration: 1000}); 

Должно быть:

this.xPosition.from(100).to(1000, 'linear', 1000); 
Animation.prototype.start = function start() { 
    // request an update to start the animation 
    this.node.requestUpdate(this.id); 
    // begin driving the animation 
    this.xPosition.from(100).to(1000, 'linear', 1000); 
    this.node.requestUpdate(this.id); 
}; 

Помните, что узла занимает все три оси setPosition(x,y,z)

Animation.prototype.onUpdate = function onUpdate() { 
    // while the transitionable is still transitioning 
    // keep requesting updates 
    if (this.xPosition.isActive()) { 
     // set the position of the component's node 
     // every frame to the value of the transitionable 
     this.node.setPosition(this.xPosition.get(), 0, 0); 
     this.node.requestUpdateOnNextTick(this.id); 
    } 
};