【问题标题】:Ionic rendering issue during swipe on iOS在 iOS 上滑动时出现离子渲染问题
【发布时间】:2018-01-11 10:42:25
【问题描述】:

在下面的视频中,正在向右滑动。在标题部分,带有All/Classes/Products 的工具栏滞后于背景图像的消失(有没有办法让背景图像跟随滑动?)黄色加号也移动了大约40px 然后消失在落后于标题其余部分的滑动/消失之后。

我的ion-header HTML 看起来像这样:

<ion-header #ionheader (touchstart)="swipe($event, 'start')" (touchend)="swipe($event, 'end')"> <!--[@slideDown]="downState"-->
  <ion-toolbar #clickme class="itemadspace" [@slideDown]="downState" no-padding> <!--[@slideDown]="downState"-->
    <!--<ion-item class="ad" no-padding no-lines>-->
    <div class="stylistview">
      <button class="stylistviewbutton" (tap)='switchView()' ion-button color="secondary">User View</button>
    </div>

    <!--</ion-item>-->
  </ion-toolbar>

  <div (tap)="loadPost()" class='pluscontainer' [@plusSlide]="downState">
    <ion-icon class='plussy' name="add"></ion-icon>
  </div>

  <div class="clickme" (tap)="toolClicked($event)">
    <ion-navbar  color="black" [@toolSlide]="toolbarState" id="iontoolbar"> <!--[@toolSlide]="toolbarState"-->
      <ion-icon class='custom-icon' name="play"></ion-icon>
      <button class="all toolbarstyle" #allF ion-button color="black" (tap)="all()">All</button>
      <button class="classes toolbarstyle" #classesFeed ion-button color="black" (tap)="products()">Classes</button>
      <button class="products toolbarstyle" #productsFeed ion-button color="black" (tap)="classes()">Products</button>
    </ion-navbar>
  </div>
</ion-header>

CSS:

ion-toolbar {
        div.toolbar-background {
            background-image: url('../img/tresemme.png') !important;
        background-repeat: no-repeat;
            background-size: cover;

        }
    }

.itemadspace {
        z-index: 1;
        top: 0;
        left: 0;
        text-align: center;
        height: 88px;
    }

.pluscontainer {
        position: absolute;
        z-index: 2;
        right: 10px;
        top: 28px;
    }

.plussy {
        font-size: 72px;
        font-weight: 700;
        color: map-get($colors, primary);
        /*position: relative;*/
    }

.toolbarstyle {
        font-size: 12px;
        padding: 0 0.5em;
        color: gray;
        background-color: black;
    }

#iontoolbar {
        z-index: 1;
        position: absolute;
        top: 88px;
        left: 0;
        background-color: black;
        color: white;
        border-bottom-style: solid;
        border-bottom-color: map-get($colors, primary);
        border-bottom-width: 4px;
    }

感谢您的帮助。

【问题讨论】:

  • 在我(诚然不是巨大的)动画经验中,最可能的罪魁祸首是某个项目在某些时候被计算得比另一个更宽。奇怪的是,加号的宽度和该条的偏移量最终可能是相同的数字。抱歉,我无法在代码方面提供帮助,但只是提供了我的观察 编辑:看起来您的标题在动画中折叠了,是向下推动加号导致栏滑出太远吗?

标签: html ios css ionic-framework swipe


【解决方案1】:

这里的问题是#iontoolbar 和 .pluscontainer 都有 CSS 定位 absolute。

有时在绝对定位和固定定位元素上运行转换会导致元素看起来好像落后了。嵌套时它们会变得更加波涛汹涌。

说实话,我不知道为什么会发生这种情况的确切细节,但根据我自己的经验,这在移动 safari 中是最糟糕的。我建议您对 HTML 和 CSS 结构进行一些调整。我的拙见没有理由解释为什么这些元素应该有position: absolute;,但可以通过相对定位轻松完成。

试一试,然后告诉我。

【讨论】:

  • 我通过将容器&lt;div&gt; 放在包含其余代码的&lt;ion-header&gt; 中,使工具栏不滞后,并且它不会滞后。无论如何,我尝试了您的建议...您的解决方案确实有助于解决滞后问题...但是如果我对position 进行更改,许多其他事情就会开始出错。在工具栏和列表之间添加了很多空白...我也有 swipeleft swiperight 在 div
  • 老实说,我对 Ionic 并不熟悉,但您也可以使用 jquery.transit 来使动画更加流畅。如果没有 jquery.transit,我不会在移动设备上做任何事情。使动画像 VKWebview 允许的那样平滑。另外,你用什么库来做滑块?
  • 我只需要更改一些动画值就可以了...谢谢!
  • 太棒了!很高兴能帮到你。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-25
  • 2013-07-30
  • 1970-01-01
  • 2019-02-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多