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

detecting / using custom fullscreen icon paths #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benjibee
Copy link

@benjibee benjibee commented Jul 4, 2018

While this may not be the best method of doing this, it works for me, and may be needed by others!

@desandro
Copy link
Member

desandro commented Jul 5, 2018

Hello! Thank you for this contribution. Yeah, I wondered if anyone would like a custom fullscreen button shapes, similar to the arrowShape option.

I would implement this feature by add two new options: viewFullscreenButtonShape and exitFullscreenButtonShape.

You can copy/paste this code before you initialize Flickity to use these options

Flickity.defaults.viewFullscreenButtonShape =
  'M15,20,7,28h5v4H0V20H4v5l8-8Zm5-5,8-8v5h4V0H20V4h5l-8,8Z';
Flickity.defaults.exitFullscreenButtonShape =
  'M32,3l-7,7h5v4H18V2h4V7l7-7ZM3,32l7-7v5h4V18H2v4H7L0,29Z';

var svgURI = 'http://www.w3.org/2000/svg';

Flickity.FullscreenButton.prototype.createIcon = function() {
  var svg = document.createElementNS( svgURI, 'svg');
  svg.setAttribute( 'class', 'flickity-button-icon' );
  svg.setAttribute( 'viewBox', '0 0 32 32' );
  // path & direction
  var path = document.createElementNS( svgURI, 'path');
  direction = this.options[ this.name + 'FullscreenButtonShape' ];
  path.setAttribute( 'd', direction );
  // put it together
  svg.appendChild( path );
  this.element.appendChild( svg );
};
// init Flickity
new Flickity( '.carousel', {
  // custom fullscreen button shapes
  viewFullscreenButtonShape: '...',
  exitFullscreenButtonShape: '...',
});

I've opened #17 to track interest

@kaleidografik

This comment has been minimized.

@metafizzy metafizzy deleted a comment from kaleidografik Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants