Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position of the cards doesn't consider the height properly #20

Open
Zack90 opened this issue Aug 26, 2016 · 0 comments
Open

Position of the cards doesn't consider the height properly #20

Zack90 opened this issue Aug 26, 2016 · 0 comments

Comments

@Zack90
Copy link

Zack90 commented Aug 26, 2016

Cards are rendered so that it is possible to see the ones behind before the active one. This works perfectly, but if the cards dimensions are set to width: 500px; height: 500px, then the ones in the back are hidden.

I have started to play with the demo to check the origin of this issue, and I have realised that it is due to the transform: translate3d() scale() css property applied to each <td-card></td-card>.

I see that inside ionic.tdcards2.js, the function which takes care of ordering the cards is connected to the var sortCards inside the directive tdCards:

var cards;
var existingCards, card;
var i, j;
var sortCards = function() {
  existingCards = $element[0].querySelectorAll('td-card');
  for(i = 0; i < existingCards.length; i++) {
    card = existingCards[i];
    card.currentIndex = i;
    if(!card) continue;
    if(i > 0) {
      (function(j) {
        $timeout(function() {
          var top = (j * 25);
          var scale = Math.max(0, (1 - (j / 10)));
          var animation = collide.animation({
            duration: 800,
            percent: 0,
            reverse: false
          })
          .easing({
            type: 'spring',
            frequency: 5,
            friction: 250,
            initialForce: false
          })
          .on('step', function(v) {
            existingCards[j].style.transform = existingCards[j].style.webkitTransform = 'translate3d(0, ' + top*v + 'px, 0) scale('+ scale*v +')';
          })
          .start();
        }, 100 * j);
      })(i);
    }
    card.style.zIndex = (existingCards.length - i);
  }
};

I think that the issue is caused by the variables top and scale. Is there a reason why these variables are defined in the following way? Could they be improved by considering also the dimensions of the cards?

Thanks in advance for your reply!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant