1

After upgrading kineticjs from 4.0.5 to 4.5.1, I get

Uncaught TypeError: Object #<Object> has no method 'transitionTo'

Following code works with the previous version:

gameLayer.transitionTo({
        duration: '0.5',
        opacity: 1,
        callback: function() {
            intervalId = setInterval(reDraw, 33);
            isInteractive = true;

        }
    });

Whats the the alternative function for transitionTo in 4.5.1

UPDATE

I opened an issue over Github, according to the guy transitionTo has been removed and it is replaced by Tween

Regards,


vim function external call

Currently my vimrc has the following key mappings:

map <leader>m :w\|!clear && rspec --drb %<cr>
map <leader>k :w\|!clear && rspec --drb %:<C-r>=line('.')<CR><cr>
map <leader>c :w\|:!clear && cucumber --drb -r ./features %<cr>
map <leader>x :w\|!clear && cucumber --drb -r ./features %:<C-r>=line('.')<CR><cr>

However I want to consolidate them into (two) functions that have the same keymap for line vs file, I've tried the following but Vim complains about missing parentheses:

function! TestCurrentLine()
  let spec = '*_spec\.rb'
  if !(expand("%") =~ spec)
    :!clear && cucumber --drb -r ./features %:<C-r>=line('.')<CR>
  else
    :!clear && rspec --drb %:<C-r>=line('.')<CR>
  end
endfunction

function! TestCurrentFile()
  let spec = '*_spec\.rb'
  if !(expand("%") =~ spec)
    :!clear && cucumber --drb -r ./features %
  else
    :!clear && rspec --drb %
  end
endfunction

map <leader>m :w\|call TestCurrentFile<cr>
map <leader>k :w\|call TestCurrentLine<cr>

Any ideas?

4

2 回答 2

3

您可以使用如下onFinish属性:

 var tween = new Kinetic.Tween({
    node: rect, 
    duration: 1,
    x: 400,
    y: 30,
    rotation: Math.PI * 2,
    opacity: 1,
    strokeWidth: 6,
    scaleX: 1.5,
    onFinish: function() {console.log('onFinish');}
  });
于 2013-05-20T15:02:56.477 回答
2

替代方案是 TweenLite。它比经典的 Kinetic 转换具有更多的功能,因此它们已被弃用,并且 TweenLite 完全适应 KineticJS 形状。

这是一个向我们展示如何使用这些转换的教程。

http://www.html5canvastutorials.com/kineticjs/html5-canvas-linear-transition-tutorial-with-kineticjs/

  var stage = new Kinetic.Stage({
    container: 'container',
    width: 578,
    height: 200
  });
  var layer = new Kinetic.Layer();
  var rect = new Kinetic.Rect({
    x: 100,
    y: 100,
    width: 100,
    height: 50,
    fill: 'green',
    stroke: 'black',
    strokeWidth: 2,
    opacity: 0.2
  });

  layer.add(rect);
  stage.add(layer);

  var tween = new Kinetic.Tween({
    node: rect, 
    duration: 1,
    x: 400,
    y: 30,
    rotation: Math.PI * 2,
    opacity: 1,
    strokeWidth: 6,
    scaleX: 1.5
  });

  // start tween after 20 seconds
  setTimeout(function() {
    tween.play();
  }, 2000);
于 2013-05-20T12:17:33.443 回答