ocsigen / ocsigen-toolkit

User interface widgets for OCaml applications
Other
32 stars 20 forks source link

[ot-carousel] Correction of the display by default of the wheel #207

Closed rodibozman closed 3 years ago

rodibozman commented 3 years ago

Small changes but needed for the wheel to display well by default.

Instead of having :

let%shared wheel ?(a = []) ?(vertical = true) ?(position = 0)
    ?transition_duration ?inertia ?allow_overswipe ?update ?disabled ?(faces = 20)
    ?(face_size = 25) content =
[...]

wich is not appropriate since we don't know how many elements will contain the wheel but there is here an arbitrary value for the faces and face_size. We now have :

let%shared wheel ?(a = []) ?(vertical = true) ?(position = 0)
    ?transition_duration ?inertia ?allow_overswipe ?update ?disabled ?faces
    ?face_size content =
[...]
let faces = Option.value faces ~default:length in
let face_size =
    Option.value face_size ~default:(int_of_float (0.8 *. float faces))
[...]

wich is better since now we still let the ability to give precise face and faces_size values but in case the optional values are not given, it is now linking the faces value to the number of element contained in the wheel and now the face_size value is linked to a value that depends on the number of faces in order to display well !

balat commented 3 years ago

Ocamlformat: not sure it is using Be Sport's default configuration. If not add the config file from Be Sport in this repository and amend the first commit.

Wheel: Still not sure abour the result (I'll show you)

rodibozman commented 3 years ago

@balat For the demo in ocsigen start there is a few changes that needs to be made in the ot_carousel.css and in demo_carousel3.eliom.

In ot_carousel.css remove this at line 167 : (in order to avoid that weird rewriting feeling when you scroll with the wheel)

    transition: opacity 2s; 

and this is very important, in demo_carousel3.eliom you need to remove the attribut ~inertia:1. at line 80 :

    Ot_carousel.wheel
      ~a:[ a_class [ "demo-carousel3" ] ]
      ~update ~vertical:true ~inertia:1. ~position:10 ~transition_duration:3.
      carousel_content

into

    Ot_carousel.wheel
      ~a:[ a_class [ "demo-carousel3" ] ]
      ~update ~vertical:true ~position:10 ~transition_duration:3.
      carousel_content

in order to let the initial wheel program use its own inertia by default that calculates the appropriate inertia to avoid this time the weird blank space that appears when you scroll to fast.

balat commented 3 years ago

No very good solution found to improve the wheel. We decided to close this subject for now.

If there are many elements, implemented solution has a weird transition effect on opacity, because we didn't want to redraw elements during movement (with inertia).

Solutions discussed: