Skip to content

Ionic V4 - ion-item-sliding getSlidingRatio() not working #16560

Closed

Description

Bug Report

Ionic Info

$ ionic info

Ionic:

   ionic (Ionic CLI)             : 4.5.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.17
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 7.1.0
   @angular/cli                  : 7.1.0
   @ionic/angular-toolkit        : 1.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.3, (and 4 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/geiringe/Android/Sdk)
   NodeJS            : v8.9.3 (/home/geiringe/.nvm/versions/node/v8.9.3/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.15

Describe the Bug
SlidingItem.getSlidingRatio() is not defined.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a basic list with ion-item-sliding
  2. Use the ionDrag event to fire function
  3. See error

Related Code
HTML:

<ion-list>
  <ion-item-sliding #item (ionDrag)="onDrag($event)">
    <ion-item>    
      <ion-row>
        <ion-col size="8" size-md="9" text-left>
          <h3>Some header 1</h3>
        </ion-col>
      </ion-row>  
    </ion-item>
    <ion-item-options side="start">
        <ion-item-option color="success">Complete</ion-item-option>
    </ion-item-options>
  </ion-item-sliding>
  <ion-item-sliding #item (ionDrag)="onDrag($event)">
    <ion-item>    
      <ion-row>
        <ion-col size="8" size-md="9" text-left>
          <h3>Some header 2</h3>
        </ion-col>
      </ion-row>  
    </ion-item>
    <ion-item-options side="start">
        <ion-item-option color="success">Complete</ion-item-option>
    </ion-item-options>
  </ion-item-sliding>
<ion-list>

Typescript:

import { Component, OnInit  } from '@angular/core';
import { ItemSliding } from '@ionic/angular';

@Component({
  selector: 'list-test',
  templateUrl: './list-test.component.html',
  styleUrls: ['./list-test.component.scss']
})
export class ListTestComponent implements OnInit {
  
  constructor() { }

  ngOnInit() {
  }

  async onDrag(item: ItemSliding) {    
    let ratio = await item.getSlidingRatio();
    //let ratio = item.detail.ratio;
  }
}

Error:

ERROR Error: Uncaught (in promise): TypeError: item.getSlidingRatio is not a function
TypeError: item.getSlidingRatio is not a function

Expected Behavior
Expect the value of the function getSlidingRatio() to return.

Workaround
You can use the item.detail.ratio property to get the value instead.

Activity

  1. manucorporat commented on Dec 6, 2018

    @manucorporat
    Contributor

    ionDrag event does not return a ItemSliding, but an event, check the detail property:

      async onDrag(ev: CustomEvent<any>) {    
    
      }
    
  2. ionitron-bot commented on Jan 5, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  3. locked and limited conversation to collaborators on Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: core

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions