Jump to content
Search Community

pakl

Business
  • Posts

    25
  • Joined

  • Last visited

Posts posted by pakl

  1. Thanks for trying to reproduce it! I'm not sure why but if you change your draggable construction options to:

    type: 'scrollTop',
    onDragEnd: restart,
    edgeResistance: 0.75,
    throwProps: true,
    onPress:function(){},
    onRelease:function(){}
    

    you will see the issue as every time you drag items are added to the container.

     

    I need to re-create the draggable because the number of items varies and updating the contents of a draggable doesn't seem to work flawlessly.

  2. Thanks for the input. For what it's worth, here is the hack I used to get around this issue without having to touch my code base too much:

    (function () {
    	var originalEmpty = jQuery.fn.empty;
    	jQuery.fn.empty = function () {
    		var draggable = Draggable.get(this);
    		if (draggable != null) {
    			draggable.kill();
    		}
    		return originalEmpty.apply(this, arguments);
    	};
    })();
    

    It just overrides the jQuery.empty method, checks for a draggable and kills it before calling the original empty logic of jQuery.

    Seems to work fine so far. Obviously this is a hack very specific to how I use both jQuery and draggable in this project.

     

    I just haven't ever encountered any issues with empty before so was suspecting draggable of doing something unusual here.

  3. I'm using a container div that I re-use when populating with different items. That div is also a draggable.

     

    Interestingly doing this:

    $(container).empty();
    //add new content to container
    
    //recreate draggable
    var draggable = Draggable.get(container);
    if (draggable != null) {
      draggable.kill();
    }
    //create new draggable here
    

    will result in the draggable to malfunction in that it suddenly contains both the old and new content which I really don't understand since the container.empty() call should clear all old content of it.

     

    Doing this:
     

    var draggable = Draggable.get(container);
    if (draggable != null) {
    	draggable.kill();
    }
    $(container).empty();
    //add new content
    //recreate draggable
    

    works just fine but it's awkward that I can't rely on $(container).empty to actually clear the div properly.

     

    How is it possible that .empty() doesn't remove content properly inside a draggable?

     

     

  4. To better illustrate what I'm after, this is what I used to do with createjs/tweenjs:

    //we are using our own heartbeat for the ticker so let's disable the default ticker
    if (createjs.Ticker) {
    	createjs.Ticker.setPaused(true);
    }
    
    Tween = createjs.Tween;
    
    //custom TweenJS.tick implementation to enable tweens to run either on game time (default) or on real time (isRealTime)
    var tweenTick = function (gameDelta, drawDelta) {
    	var tweens = createjs.Tween._tweens.slice(); // advancing tweens can create new or delete existing tweens.
    	for (var i = tweens.length - 1; i >= 0; i--) {
    		var tween = tweens[i];
    		var ticks = tween._useTicks ? 1 : tween.isRealTime ? drawDelta : gameDelta;
    		if (ticks && !tween._paused) {
    			tween.tick(ticks);
    		}
    	}
    };
    
    //I would then call tweenTick in my drawloop
    

    Is there a similar array of tweens? or a .tick() method I can replace?

     

    I need to make sure that those animations run at the exact same heartbeat than the rest of the game logic.

  5. Can you point me to where I can find this ticker?

     

    I don't mind hijacking the method and making this a special case for my projects but not having the ability to provide a custom heartbeat to all or some tweens is a major hindrance and setting a timescale on some tweens is just not the same. For one, I still need the ability of a timeScale on those tweens and workarounds to multiply into current timescales seems extraordinarily hacky for something that is as simple as 'provide a different delta on tick'.

  6. I want to be able to flag specific tweens (or timelines) and then advance these tweens based on a custom heartbeat that does not progress in real time.

     

    Use case: I want to use greensock for both UI animations but also for animating in-game objects. While UI animations always run in real time, game animations should run in game time and can be slowed down, sped up or paused entirely.

     

    In other libraries I usually overwrote a static .tick method and then filtered out the flagged tweens and provided a different delta in the tick call for those objects but I'm having trouble finding the right method in greensock to achieve this.

  7. I stumbled upon another oddity when using splittext on a text with line breaks:

     
    <div class="test1">This results <br>in six words.</div>

    results in six words and one linebreak.

    <div class="test2">This results  <br>in seven words.</div>

    results in seven words (one of which is empty) and what looks like two linebreaks. The difference between test1 and test2 is that the second one has two spaces before the linebreak.

     

    Since a space is normally not treated as a word, this seems like a bug to me. Multiple spaces should be treated the same as a single space.

     

     

    Demo here:

     

     

    See the Pen wFkbL by patrickklug (@patrickklug) on CodePen

  8. @Jack what is the best way to link to the latest version in a codepen?

     

    I tried the new version locally and it seems that there is a breaking bug.

     

    Using splittext on 'This is a test<br><br>Normal italic bold underline' returns a `.words` array with only 3 elements.

  9. I'm working on applying styling to certain words after using SplitText. To do this I'm relying on the word index but I see some inconsistencies when a linebreak is considered a word and when it isn't.

     

    The following pen illustrates:

     

     

    As you can see when a linebreak is followed or preceded by a space it will end up as a separate line and word after SplitText but if two or more linebreaks are not separated by anything else, they are combined into one line/word.

     

    I think it's fair to consider this a bug. A linebreak should always end up as its own line with its own word, or am I missing something?

    See the Pen goGuA by patrickklug (@patrickklug) on CodePen

  10. I see. Thanks for your help!

     

    I didn't expect that I need to set this. I'm sure there is a reason but I fail to see why this is necessary. I'm trying to animate to different sets of properties. Why do I need to specify both a from and to?

     

    EDIT: was posting at the same time as jamiejefferson. makes sense now. thanks for the clarification.

    • Like 1
  11. Just starting with GCAP. It's my understanding that .fromTo allows me to specify two different sets of values to achieve both a to and from tweening in one step.

     

    I tried to use this in the following example:

    var tl = new TimelineMax();
    
    
    tl.from('#test', 1, {
    left: -50,
    });
    
    
    tl.fromTo('#test2', 1, {
    left: -50
    },{
      color : 'red'
    });

    example here: 

     

    to my surprise #test2 only seems to do the 'to' part but no longer the 'from' left animation.

     

    What am I missing?

     

    See the Pen dGCsy by patrickklug (@patrickklug) on CodePen

×
×
  • Create New...