Skip to content

Commit

Permalink
BUGFIX upgrading to v4 may cause slider speed to be 0 (#182)
Browse files Browse the repository at this point in the history
* BUGFIX upgrading to v4 may cause slider speed to be 0

* UPDATE multiply either speed int by 1000

* UPDATE correct test

* PHPCS
  • Loading branch information
muskie9 authored May 30, 2019
1 parent 44cd543 commit c961935
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/ORM/FlexSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public function populateDefaults()
$this->owner->CarouselControlNav = 0;
$this->owner->CarouselDirectionNav = 1;
$this->owner->CarouselThumbnailCt = 6;
$this->owner->FlexSliderSpeed = $this->owner->config()->get('flex_slider_speed')
?: Config::inst()->get(FlexSlider::class, 'FlexSliderSpeed');
$this->owner->FlexSliderSpeed = $this->getDefaultSpeed();

return parent::populateDefaults();
}
Expand Down Expand Up @@ -274,7 +273,20 @@ public function getCustomScript()
*/
public function getSlideshowSpeed()
{
return $this->owner->FlexSliderSpeed * 1000;
$speed = $this->owner->FlexSliderSpeed > 0
? $this->owner->FlexSliderSpeed
: $this->getDefaultSpeed();

return $speed * 1000;
}

/**
* @return mixed
*/
protected function getDefaultSpeed()
{
return $this->owner->config()->get('flex_slider_speed')
?: Config::inst()->get(FlexSlider::class, 'flex_slider_speed');
}

/**
Expand Down
6 changes: 5 additions & 1 deletion tests/FlexSliderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ public function testGetSlideshowSpeed()
{
/** @var \Dynamic\FlexSlider\ORM\FlexSlider|\Page $object */
$object = TestPage::create();
$this->assertEquals(7000, $object->getSlideshowSpeed());
$object->FlexSliderSpeed = 0;
$this->assertEquals(
Config::inst()->get(FlexSlider::class, 'flex_slider_speed') * 1000,
$object->getSlideshowSpeed()
);

$object->FlexSliderSpeed = 0.5;
$object->write();
Expand Down

0 comments on commit c961935

Please sign in to comment.