How to get away with the Parallax effect with angular?

0

How can I get rid of the parallax action when it has an attribute?

is the tag that has the attribute:

<parallax-image ng-class="{{fixo}}" 
src="/parallax-image/assets/images/image-01.jpg"></parallax-image>

This is the css that has the attribute:

[class^="fixo"] {
  background-color: color($grey, 200);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  display: block;
  height: 0;
  overflow: hidden;
  padding-bottom: 40%;
  position: relative;
  width: 100%;
}

And js is this:

if ('.fixo' == true) {
   return true;
} else {
  return false;
}
    
asked by anonymous 23.05.2016 / 16:14

1 answer

0

Your use of ng-class is wrong. The correct definition would be:

ng-class="{'fixo': meuValor}" //Onde "meuValor" é um $scope do controller ex.: $scope.meuValor

In this case, the fixo class will be added when $scope.meuValor is true

Another method, if you want to define a class OR another based on the same value, would be:

ng-class="meuValor ? 'fixo' : 'nao-fixo'"

In this case, if the $scope.meuValor is true , the fixo class will be added if the nao-fixo class is not added.

Note that your JS should change to something like this:

if( 'algum comparativo') {
    $scope.meuValor = true;
else {
    $scope.meuValor = false;
}

As you have not provided much information, this part of the logic depends on your context, but with this information I believe you can solve the problem.

    
23.05.2016 / 17:07