Comments (6)
@jon64digital hey, have you solved this problem, I got the same issue.
I have tried @Kenishi method, but it does not work for me
from angular-slick.
For what it is worth, I am using angular-slick and do not have any issue. Here is part of my code:
<div class="row">
<slick init-onload="true" infinite="false" slides-to-scroll="1" swipe-to-slide="true" touch-move="true"
touch-threshold="1000" dots="false" responsive="breakpoints" edge-friction="0" data="entries"
class="slider lazy" css-ease="linear" style="max-width:1024px; margin-bottom: 10px">
<div ng-repeat="entry in entries" class="untventry" style="position:relative;">
<a href="#/entry/{{entry.linkName}}?list={{selectedCat.name}}">
<div id="entry" class="mycontainer">
<img id="entryimage" ng-src="{{entry.imageUrl}}" style=" -webkit-filter: grayscale(100%); filter:grayscale(100%)"/>
from angular-slick.
I'm not sure if this will help you but I had a similar issue and fixed it somewhat this way. The elements still flash briefly and it causes elements still move around, but I don't end up with a giant list not in a carousel. If you want it 100%, then make sure to call your beforeSlick() before you initialize/update the carousel data. My situation is a little unique too because my carousel data is dynamic (updates via socket.io) and the DOM wasn't updating, I found the ng-if worked to trigger angular to redraw the DOM. Anyway, you can give this a shot.
In the angular slick JS file:
scope: {
....
prevArrow: '@',
nextArrow: '@',
// I'm not 100% sure these need to be '=' but this is what worked for me
beforeLoad: '=',
afterLoad: '='
}
link: function (scope, element, attrs) {
....
initializeSlick = function () {
var currentIndex, customPaging, slider;
slider = $(element);
// Let the controller know we are about to slick it
if(scope.beforeSlick) {
scope.beforeSlick();
}
....
slider.on('afterChange', function (event, slick, currentSlide) {
if (scope.onAfterChange) {
scope.onAfterChange(slick, currentSlide);
}
if (currentIndex != null) {
return scope.$apply(function () {
currentIndex = currentSlide;
return scope.currentIndex = currentSlide;
});
}
});
if(scope.afterSlick) {
// We call the callback in timeout to make sure everything has been slicked
$timeout(function() {
scope.afterSlick();
});
}
Here's some Jade showing how I'm doing it:
slick(ng-if="dataLoaded" before-slick="beforeSlick" after-slick="afterSlick" init-onload="true" infinite="true" data="entries" )
div.listItem(ng-repeat="entry in entries")
.row
.col-sm-12
img(ng-src="{{url}}")
.row
.col-sm-12
span {{entry.text}}
In the controller.js that the carousel sits in:
$scope.beforeSlick = function() {
$(".listItem").hide();
};
$scope.afterSlick = function() {
$(".listItem").show();
};
from angular-slick.
@Kenishi I think your example code should be:
scope: {
data: '=',
initialSlide: '@',
beforeSlick: '=',
afterSlick: '='
// ... options ...
},
Thanks for sharing.
from angular-slick.
@jon64digital Not sure if you used one of the solutions above, what I did was to make the wrapping element width span the 9 items Im initially loading, in the largest state available and floated them to the left before the slick dom elements are generated and slick-initialized is added as a class.
/ Handles view before Slick Initializes
slick:not(.slick-initialized) {
min-width: 2,048px;
display: block;
.video-wrap {
float: left;
margin-right: $line-height-computed/2;
}
}
This mimics the position. of when slick is initialized. We also found that lazy loading is absolutely needed for our case, so we limited our initial load to 9 items per slider and have 3 displaying.
Would say that you can pair it with @Kenishi 's solution as well. So we all know that this repo is not very well maintained, you should checkout this issue slick/issues/1005 - regarding kenwheeler/slick#1005 so that the on-load executes in the correct manner.
Also see #100
on Slick.js dist we ended up with:
if (attrs.onInit) {
scope.onInit();
}
if (typeof currentIndex !== "undefined" && currentIndex !== null) {
return sl.slideHandler(currentIndex);
}
});
slider.slick({
....
});
slider.on('reInit', function(sl) {
if (attrs.onReInit) {
return scope.onReInit();
}
});
slider.on('setPosition', function(sl) {
if (attrs.onSetPosition) {
return scope.onSetPosition();
}
});
slider.on('swipe', function(sl) {
if (attrs.onSwipe) {
return scope.onSwipe();
}
});
slider.on('breakpoint', function(sl) {
if (attrs.onBreakpoint) {
return scope.onBreakpoint();
}
});
slider.on('destroy', function(sl) {
if (attrs.onDestroy) {
return scope.onDestroy();
}
});
slider.on('edge', function(sl) {
if (attrs.onEdge) {
return scope.onEdge();
}
});
from angular-slick.
@Kenishi Thank you so much! This method really works for me.
from angular-slick.
Related Issues (20)
- slick execution in ng-repeat HOT 2
- Unslick failure
- Can't swipe back with swipe to slide HOT 1
- Slide when number of slide is less than or equal to slides-to-show HOT 2
- Using boolean('false') always returns true HOT 1
- useCSS property does not work
- Bug doesnt display anything until autoplay begins HOT 1
- slides to scroll setting is not working in last page
- As-nav-for is not working with touch.
- Dragging makes my list disappear HOT 3
- angular slick carousel does not respect viewBox of the ng-md-icon
- ng-click on mobile dont work HOT 1
- Can't disable draggable property
- how to ban cycle?
- how to init current-index
- Cannot read property 'add' of null
- slider.unslick is not a function
- Dragend triggers click
- Passing Slick as dependency with ng-route does not load it HOT 2
- $ is not a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-slick.