Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
fix navigation/pagination controls not rendering via options hash (#81)
Browse files Browse the repository at this point in the history
* fix navigation/pagination controls not rendering when configured by  hash

* fix README badge and demo link references
  • Loading branch information
Matt-Jensen authored Dec 1, 2017
1 parent af10d0c commit d44dbe2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Ember-cli-swiper [![Build Status](https://travis-ci.org/Suven/ember-cli-swiper.svg?branch=master)](https://travis-ci.org/Suven/ember-cli-swiper) [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-swiper.svg)](https://emberobserver.com/addons/ember-cli-swiper) [![Code Climate](https://codeclimate.com/github/Suven/ember-cli-swiper/badges/gpa.svg)](https://codeclimate.com/github/Suven/ember-cli-swiper)
# Ember-cli-swiper [![Build Status](https://travis-ci.org/ember-swiper/ember-cli-swiper.svg?branch=master)](https://travis-ci.org/ember-swiper/ember-cli-swiper) [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-swiper.svg)](https://emberobserver.com/addons/ember-cli-swiper) [![Code Climate](https://codeclimate.com/github/ember-swiper/ember-cli-swiper/badges/gpa.svg)](https://codeclimate.com/github/ember-swiper/ember-cli-swiper)

Simple ember-wrapper around [Swiper by idangerous](http://idangero.us/swiper/demos/).

See the [demo](http://suven.github.io/ember-cli-swiper/) for examples and usage-infos.
See the [demo](http://ember-swiper.github.io/ember-cli-swiper/) for examples and usage-infos.

## Installation

Expand Down
15 changes: 15 additions & 0 deletions addon/components/swiper-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getProperties, computed } from '@ember/object';
import { once } from '@ember/runloop';
import { warn } from '@ember/debug';
import { assign as emAssign } from '@ember/polyfills';
import { or } from '@ember/object/computed';

import layout from '../templates/components/swiper-container';

Expand Down Expand Up @@ -62,6 +63,20 @@ export default Component.extend({
*/
_updateForInternal: '',

/**
* Render navigation controls
* @public
* @type {Boolean}
*/
hasNavigation: or('options.navigation', 'navigation'),

/**
* Render pagination controls
* @public
* @type {Boolean}
*/
hasPagination: or('options.pagination', 'pagination'),

/**
* Single Attribute options
* @public
Expand Down
4 changes: 2 additions & 2 deletions addon/templates/components/swiper-container.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{{yield (hash slide=(component "swiper-slide"))}}
</div>

{{#if pagination}}
{{#if hasPagination}}
<div class="swiper-pagination"></div>
{{/if}}

{{#if navigation}}
{{#if hasNavigation}}
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
{{/if}}
9 changes: 9 additions & 0 deletions tests/integration/components/swiper-container-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ test('pagination node is present if requested', function(assert) {

this.render(hbs`{{#swiper-container pagination=".custom-pagination"}}<div class="custom-pagination"></div>{{/swiper-container}}`);
assert.ok(this.$('.custom-pagination').hasClass('swiper-pagination-clickable'));

this.set('opts', { pagination: true });
this.render(hbs`{{swiper-container options=opts}}`);
assert.ok(this.$('>:first-child').has('.swiper-pagination').length);
});

test('navigation buttons are present if requested', function(assert) {
Expand All @@ -84,6 +88,11 @@ test('navigation buttons are present if requested', function(assert) {
this.render(hbs`{{swiper-container navigation=true}}`);
assert.ok(this.$('>:first-child').has('.swiper-button-next').length);
assert.ok(this.$('>:first-child').has('.swiper-button-prev').length);

this.set('opts', { navigation: true });
this.render(hbs`{{swiper-container options=opts}}`);
assert.ok(this.$('>:first-child').has('.swiper-button-next').length);
assert.ok(this.$('>:first-child').has('.swiper-button-prev').length);
});

test('it supports `effect` attribute', function(assert) {
Expand Down

0 comments on commit d44dbe2

Please sign in to comment.