pulyaevskiy / parallax-image

A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content.
BSD 3-Clause "New" or "Revised" License
279 stars 33 forks source link

There is no parameter for speed/rate #7

Open mariolourobert opened 4 years ago

mariolourobert commented 4 years ago

A parameter for speed/rate, or, in an another point of view, the z-index of the image, may be a good improvement ?

bruckmatthew commented 4 years ago

This should be an easy fix. A rate property needs to be included and insterted to the code here at line 210 in parallax_image.dart:

Alignment alignment; if (_scrollPosition.axis == Axis.vertical) { double value = rate(_position.dy / _screenSize.height - 0.5).clamp(-1.0, 1.0); alignment = new Alignment(0.0, value); } else { double value = rate(_position.dx / _screenSize.width - 0.5).clamp(-1.0, 1.0); alignment = new Alignment(value, 0.0); }

I've played aroud with changing the values in the package code and negative values work well.

Apologies for not just doing it as I've not edited plugins before. Granted i gave it a try, but it came up with errors. @pulyaevskiy