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

Carousel view not working on the Browser #5668

Closed
guruprasaad123 opened this issue Feb 16, 2018 · 1 comment
Closed

Carousel view not working on the Browser #5668

guruprasaad123 opened this issue Feb 16, 2018 · 1 comment

Comments

@guruprasaad123
Copy link

guruprasaad123 commented Feb 16, 2018

I am developing a SPA using vuejs with materialize-css.I want to use carousal-slider in my project and I have read this official Document.Here's the code i tried.

App.vue

<template>
  <div id="app">

    <div class="navbar-fixed">
    <nav>
     ...
    </nav>
  </div> <!--navbar fixed end -->

  <div class="carousel carousel-slider center ">
    <div class="carousel-fixed-item center">
      <a class="btn waves-effect white grey-text darken-text-2">button</a>
    </div>
    <div class="carousel-item red white-text" href="#one!">
      <h2>First Panel</h2>
      <p class="white-text">This is your first panel</p>
    </div>
    <div class="carousel-item amber white-text" href="#two!">
      <h2>Second Panel</h2>
      <p class="white-text">This is your second panel</p>
    </div>
    <div class="carousel-item green white-text" href="#three!">
      <h2>Third Panel</h2>
      <p class="white-text">This is your third panel</p>
    </div>
    <div class="carousel-item blue white-text" href="#four!">
      <h2>Fourth Panel</h2>
      <p class="white-text">This is your fourth panel</p>
    </div>

</div>

  </div>

</template>

<script>
import M from 'materialize-css';

export default {
  mounted(){
 var elem = document.querySelector('.sidenav');
  var navigation = M.Sidenav.init(elem,{});

 var carousel = M.Carousel.init({
    fullWidth: true,
    indicators: true
  });

  },
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',

    }
  }
}
</script>

<style lang="scss">
@import url("https://fonts.googleapis.com/icon?family=Material+Icons");
@import url("https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/css/materialize.min.css");

</style>

Here's the screenshot of the weird behaviour of the carousel-view in chrome browser.
capture4

But the View I expected was...

capture5

@Dogfalo
Copy link
Owner

Dogfalo commented Feb 16, 2018

Seems like you are missing the element reference

var carousel = M.Carousel.init(element, {
    fullWidth: true,
    indicators: true
  });

@acburst acburst closed this as completed Feb 28, 2018
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

3 participants