1

I added a paralla code to my page, but the images don't appear, when I remove the class "parallax" from container of the image, images appear but without the parallax effect,

  <div class="parallax-container">
    <div class="parallax"><img src="content/img/wood.jpg"></div>
  </div>
  <div class="section white">
    <div class="row container">
      <h2 class="header">Parallax</h2>
      <p class="grey-text text-darken-3 lighten-3">Parallax is an effect where the background content or image in this case, is moved at a different speed than the foreground content while scrolling.</p>
    </div>
  </div>
  <div class="parallax-container">
    <div class="parallax"><img src="content/img/wood.jpg"></div>
  </div>


<script type="text/javascript">
var elem = document.querySelector('.parallax');
var instance = M.Parallax.init(elem, options);

// Or with jQuery

$(document).ready(function(){
$('.parallax').parallax();
});

</script>

and these are the libraries I added

  <script src="app\lib\angular.min.js"></script>
  <script src="app\lib\angular-route.min.js"></script>
  <script src="app\lib\angular-aria.min.js"></script>
  <script src="app\lib\angular-messages.min.js"></script>
  <script src="app\lib\angular-animate.min.js"></script>
  <link rel="stylesheet" href="app\lib\angular-material.min.css">
  <script src="app\lib\angular-material.min.js"></script>
  <link rel="stylesheet" href="content/css/styles.css">
  <!--Materialize-->
  <link href="materialize\css\icon.css" rel="stylesheet">
  <link rel="stylesheet" href="materialize/css/materialize.min.css">
  <link rel="stylesheet" href="app\lib\Roboto.css">
  <script src="app\app.js"></script>
<script type="text/javascript" src="materialize\js\jquery.3.2.1.min.js"></script>
   <script src="materialize\js\materialize.min.js"></script>
kach haja
  • 43
  • 4

1 Answers1

0

Your error lies in trying to init the function twice in your Javascript code. Also (well at least on my end), I do occasionally receive errors using vanilla JS while intializing components for materialize. What you could do: (remove the vanilla JS code and add this to the end of your file, preferably below the end of body tag)

<script>
 $(document).ready(function(){
  $('.parallax').parallax();
 });
</script>

Make sure you call the jquery before the materialize script like so:

 <script type="text/javascript" src="materialize\js\jquery.3.2.1.min.js"> 
 </script>
 <script src="materialize\js\materialize.min.js"></script>
Rohan Mayya
  • 196
  • 1
  • 2
  • 12