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 #105

Merged
merged 5 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions public/assets/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions public/assets/avatar1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript" src="elm.js"></script>
<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css" media="screen">
<link rel="stylesheet" href="style.min.css" />
</head>
<body>
<script>
var app = Elm.Main.fullscreen();
</script>
<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>
<script> var app = Elm.Main.fullscreen() </script>
<script src="ports.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions public/ports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
app.ports.begin.subscribe(function() {
window.requestAnimationFrame(function() {
var element = document.getElementsByClassName("makecarousel")[0];
console.log("ELEMENT", element);
var flkty = new Flickity(element, {
lazyLoad: true,
adaptiveHeight: true,
wrapAround: true,
prevNextButtons: false,
pageDots: true
});
});
});
25 changes: 25 additions & 0 deletions src/css/_custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,28 @@
.lh-f7 {
line-height: 13px;
}

/* Carousel */

.carousel-cell {
opacity: 0.2;
-webkit-overflow-scrolling: touch;
}

.carousel-cell.is-selected {
opacity: 1;
}

.makecarousel {
-webkit-overflow-scrolling: touch;
}

.dot.is-selected {
background: var(--green);
transform: scale(1.1);
transition: 1s;
}

.smooth {
transform: translate3d(0, 0, 0);
}
2 changes: 1 addition & 1 deletion src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ main =
{ init = init
, view = view
, update = update
, subscriptions = always Sub.none
, subscriptions = subscriptions
}
3 changes: 1 addition & 2 deletions src/elm/Router.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Router exposing (..)
import Data.View exposing (getCurrentView, getViewFromRoute)
import Html exposing (..)
import Html.Attributes exposing (..)
import Navigation exposing (..)
import Types exposing (..)


Expand All @@ -13,6 +12,6 @@ view model =
view =
getCurrentView model
in
div [ class "w-100 fixed overflow-y-scroll top-0 bottom-0 m0-auto cover", id "container" ]
div [ class "w-100 fixed overflow-y-scroll top-0 bottom-0 m0-auto cover flex justify-center items-center", id "container" ]
[ view
]
17 changes: 14 additions & 3 deletions src/elm/State.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module State exposing (..)
port module State exposing (..)

import Data.Log exposing (defaultLog)
import Data.Stim exposing (defaultStim)
import Data.View exposing (getViewFromRoute, viewFromUrl)
import Navigation exposing (..)
import Helpers exposing (scrollToTop)
import Navigation exposing (..)
import Types exposing (..)


Expand All @@ -24,13 +24,16 @@ initModel =
}


port begin : () -> Cmd msg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sophielevens @maxgerber Can you make this name more declarative? Also could you make a Ports.elm and put all ports in there?



init : Navigation.Location -> ( Model, Cmd Msg )
init location =
let
model =
viewFromUrl location initModel
in
model ! []
model ! [ begin () ]


update : Msg -> Model -> ( Model, Cmd Msg )
Expand All @@ -39,5 +42,13 @@ update msg model =
UrlChange location ->
{ model | view = getViewFromRoute location.hash } ! [ scrollToTop ]

MakeCarousel ->
model ! []

NoOp ->
model ! []


subscriptions : Model -> Sub msg
subscriptions model =
Sub.none
1 change: 1 addition & 0 deletions src/elm/Types.elm
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ type Feeling
type Msg
= NoOp
| UrlChange Navigation.Location
| MakeCarousel
Loading