GithubHelp home page GithubHelp logo

Comments (4)

roman-rr avatar roman-rr commented on May 13, 2024 4

@Andranik0 Check out v.1.1.51
New property followerElement implemented.

Try it out:

  drawer: CupertinoPane;
  constructor() {}

  ngOnInit() {
    this.drawer = new CupertinoPane('.cuper', {
      followerElement: 'ion-fab',
      buttonClose: false,
      initialBreak: 'bottom',
      breaks: {
        top: { enabled: true, offset: 290 },
        middle: { enabled: false },
        bottom: { enabled: true, offset: 110 },
      },
    });

    this.drawer.present({animated: true});
  }
<ion-content [fullscreen]="true">
  <ion-fab horizontal="end" vertical="center">
    <ion-fab-button size="small">
      <ion-icon name="add"></ion-icon>
    </ion-fab-button>
  </ion-fab>

  <div class="cuper">
    <h1>Header</h1>
    <p>Content</p>
  </div>
</ion-content>

from panes.

roman-rr avatar roman-rr commented on May 13, 2024

@Andranik0

In this example ion-fab following pane onDrag events.
You can complete behavior for other events with similar way.
Feel free to ask if you stuck on some moment.

<ion-content [fullscreen]="true">
  <ion-fab horizontal="end" vertical="bottom" id="fab-button">
    <ion-fab-button>
      <ion-icon name="add"></ion-icon>
    </ion-fab-button>
  </ion-fab>

  <div class="cupertino-pane">
    <h1>Header</h1>
    <p>Content</p>
  </div>
</ion-content>
  public drawer: CupertinoPane;
  public fabButton: HTMLElement;
  constructor() {}

  ngOnInit() {
    this.fabButton = document.getElementById('fab-button');

    this.drawer = new CupertinoPane('.cupertino-pane', {
      onDrag: (ev) => {
        this.fabButton.style.bottom = `${window.innerHeight}px`;
        this.fabButton.style.transform = `translateY(${this.getPaneTransformY}px)`;
      }
    });
    this.drawer.present();
  }

  get getPaneTransformY():number {
    const translateYRegex = /\.*translateY\((.*)px\)/i;
    return parseFloat(translateYRegex.exec((<any>document.querySelector('.pane')).style.transform)[1]);
  }

from panes.

Andranik0 avatar Andranik0 commented on May 13, 2024

Hi @roman-rr,

Thanks for your answer.

Unfortunately, it seems it does not fully take into account the elasticity/bounce property of the pane's moves, and thus leads to unexpected behaviors at the end of the drag.

Could it be possible to directly integrate the fabButton to the pane component in order to display it right above the "draggable" section (to get something similar to the already existing "close button" but outside the pane)? Or maybe fix the behavior described above regarding the use of onDrag?

Some screenshots to let you understand my issue:
2020-05-17_11h11_01
(works while we drag: "bottom" of the fabButton is properly set)

2020-05-17_11h11_17
2020-05-17_11h11_22
(does not work once we stop dragging: "bottom" of the fabButton is set at the drag end and does not follow the animation / the pane's rebound)

TS code:

  drawer: CupertinoPane;
  fabButton: HTMLElement;

  constructor() {}

  ngOnInit() {
    this.fabButton = document.getElementById('fab-button');
    this.drawer = new CupertinoPane('.cuper', {
      onDrag: (ev) => {
        this.fabButton.style.bottom = `${window.innerHeight}px`;
        this.fabButton.style.transform = `translateY(${this.getPaneTransformY}px)`;
      },
      buttonClose: false,
      initialBreak: 'bottom',
      breaks: {
        top: { enabled: true, offset: 290 },
        middle: { enabled: false },
        bottom: { enabled: true, offset: 110 },
      },
    });

    this.drawer.present();
  }

  get getPaneTransformY(): number {
    const translateYRegex = /\.*translateY\((.*)px\)/i;
    return parseFloat(translateYRegex.exec((<any>document.querySelector('.pane')).style.transform)[1]);
  }

HTML code:

<ion-content [fullscreen]="true">
  <ion-fab id="fab-button" horizontal="end" vertical="bottom">
    <ion-fab-button size="small">
      <ion-icon name="add"></ion-icon>
    </ion-fab-button>
  </ion-fab>
  <div class="cuper">
    <h1>Header</h1>
    <p>Content</p>
  </div>
</ion-content>

Thanks a lot!

Andra

from panes.

Andranik0 avatar Andranik0 commented on May 13, 2024

Hi @roman-rr,

It works perfectly! Good job!

Thanks,

Andra

from panes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.