小编the*_*het的帖子

Flutter:为用户滚动增加摩擦,而不是弹簧

我有一个带有自定义滚动物理类的列表视图,它定义了我想要的列表的滚动和弹簧效果。我已经设法按照我想要的方式设置弹簧阻尼,但我似乎找不到任何设置来使用户的阻力变

我的意思是,当用户拖动时,我希望列表感觉它有张力,因此用户需要比平时拖动得更远,我将使用自定义滚动物理处理列表中下一个项目的移动.

我希望它感觉像在火车站的转弯风格。你的身体会承受很多压力,一旦你通过转弯,风格就会重置为中心。

列表:

child: ListView.builder(
  cacheExtent: MediaQuery.of(context).size.height * 2,
  padding: EdgeInsets.only(top: 0),
  itemExtent: constraints.maxHeight -
      SizeConfig.blockSizeVertical * 40,
  itemCount: channelList?.length ?? 0,
  controller: _controller,
  physics: _physics,
  itemBuilder: (BuildContext context, int index) =>
      buildList(index),
),
Run Code Online (Sandbox Code Playgroud)

自定义滚动类:

import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';

class CustomScrollPhysics extends ScrollPhysics {
  final double itemDimension;
  static final SpringDescription customSpring =
      SpringDescription.withDampingRatio(
    mass: 4,
    stiffness: 150.0,
    ratio: 2.0,
  );

  @override
  double get dragStartDistanceMotionThreshold => 40;

  @override
  double get minFlingVelocity => double.infinity;

  @override
  double get …
Run Code Online (Sandbox Code Playgroud)

listview scroll flutter

14
推荐指数
1
解决办法
944
查看次数

Firebase 3.0会话持久性

在firebase 3.0中使用会话持久性似乎是不可能的.

这在以前的版本中是可行的:https: //www.firebase.com/docs/web/guide/login/password.html

authWithPassword()接受一个可选的第三个参数,该参数是包含以下任何设置的对象:

remember - String
如果未指定 - 或设置为default,只要您在App Dashboard的Login&Auth选项卡中配置,会话就会保持不变.要将持久性限制为当前窗口的生命周期,请将其设置为sessionOnly.值none将不会保留身份验证数据,并且会在页面关闭后立即结束身份验证.

在3.0版中,没有提及可选的第3个参数:https: //firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword

signInWithEmailAndPassword(email,password)
返回包含非null firebase的firebase.Promise.

此外,在新的控制台(https://console.firebase.google.com/)中,我找不到更改默认持久性的选项.

session persistence firebase firebase-authentication

7
推荐指数
2
解决办法
7560
查看次数

HTTPS请求仅在iOS,Ionic 2上失败

我有一个Ionic 2应用程序调用Spring BootAPI将推送通知发送到其他设备.API使用HTTPS配置.

API POST请求适用于除外的 所有内容iOS.

我在服务器上的SSL证书是自签名的(可能就是这样吗?).

适用于:

  • 离子发球
  • Android的
  • 邮差
  • 卷曲

这是请求:

public sendNotificationRequest(title: string, action: string, name: string, tokens: any, notifications: boolean) {
    // Check if user turned off notifications
    if(!notifications) {
        return;
    }

    let headers = new Headers({'Content-Type': 'application/json'});
    headers.append('Authorization', 'Basic ' + btoa(this.username_decrypted + ':' + this.password_decrypted));
    let body = this.formObj(tokens, title, action, name);
    console.log(body);

    this.http.post("https://<some-url>",
                    body, { headers: headers }
    ).subscribe((response) => {
        console.log("HTTPS RESPONSE");
        console.log(response);
    }, …
Run Code Online (Sandbox Code Playgroud)

api https spring-boot ionic2

6
推荐指数
1
解决办法
7931
查看次数

如何动态更新嵌套的mat-tree

我有一个Angular材质组件,正在尝试使用新数据动态更新。

@ViewChild('tree') tree: MatTree<any>;
...
treeControl: NestedTreeControl<any>;
dataSource: MatTreeNestedDataSource<any>;
...
// This does not work
this.tree.renderNodeChanges(newData);
Run Code Online (Sandbox Code Playgroud)

我可以很好地更改数据源数据,它会反映在日志中,但是永远不会重新渲染树this.dataSource.data = newData

这些数据是从可观察的对象中检索的,每次发生更改时,我都会通过它。

<mat-tree [dataSource]="dataSource"
  [treeControl]="treeControl"
  #tree
  class="release-notes-tree">
  ...
</mat-tree>
Run Code Online (Sandbox Code Playgroud)

仅传递全新数据并更新树的最简单方法是什么?

angular-material

6
推荐指数
1
解决办法
5677
查看次数

Ng-repeat不会随阵列更改而更新

我已经查看了这个问题好几个小时,并阅读了许多其他似乎完全相同的问题,我已经尝试了他们的每一个解决方案,但似乎都没有.

我有一个对象数组(instructionObj.instructions),这些对象重复使用ng-repeat,他们的模板是一个指令.

<div instruction-directive ng-repeat="i in instructionsObj.instructions"> </div>
Run Code Online (Sandbox Code Playgroud)

然后我允许使用Jquery UI排序项目.

var first, second;
$( ".sort" ).sortable({
  axis: "y",
  start: function( event, ui ) {
      first = ui.item.index();
  },
  stop: function( event, ui ) {
      second = ui.item.index();
      console.log(first + " " + second);
      rearrange(first, second);
      $scope.$apply();
  }
});
Run Code Online (Sandbox Code Playgroud)

然后,我访问正在移动的对象的开始和结束索引,并相应地重新排列数组:

function rearrange(f, s){
    $timeout(function () {
        $scope.instructionsObj.instructions.splice(s, 0,
            $scope.instructionsObj.instructions.splice(f, 1)[0]);
        $scope.$apply();
    });
}
Run Code Online (Sandbox Code Playgroud)

所有这些在大多数情况下都很有效.在一种情形中,我发现了故障是重排的对象本身(一列是在屏幕上显示的所有对象的当前位置)时:

a | b | c | d | 一个

b | c | …

javascript arrays jquery angularjs

5
推荐指数
1
解决办法
2577
查看次数

VueJs:TypeError:Object(...) 不是函数,“withScopeId”

最近几周,我们一直在成功地将更新推送到我们的 Vue 应用程序,在昨天进行了一些非常小的更改(属性名称更改并删除了一些纯语义字符)之后,我们遇到了以下错误:

Uncaught TypeError: Object(...) is not a function
    at Module.fae3 (XCustomerServiceOptionsLibrary.umd.js:53612)
    at n (XCustomerServiceOptionsLibrary.umd.js:30)
    at 0012 (XCustomerServiceOptionsLibrary.umd.js:94)
    at XCustomerServiceOptionsLibrary.umd.js:11
    at XCustomerServiceOptionsLibrary.umd.js:3
    at Object.e977 (XCustomerServiceOptionsLibrary.umd.js:1)
    at o (app.2df3392d.js:formatted:39)
    at CustomerServiceManagement.umd.js:3
    at Object.7091 (CustomerServiceManagement.umd.js:1)
    at o (app.2df3392d.js:formatted:39)
Run Code Online (Sandbox Code Playgroud)

我们调试了代码,发现出现在这一行的错误:

const _withId = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withScopeId"])("data-v-569a422e")
Run Code Online (Sandbox Code Playgroud)

我们将 Vue 组件构建到库中,将它们推送到 Verdaccio 存储库,然后将它们作为依赖项添加到更大的项目中。问题 ( XCustomerServiceOptionsLibrary) 中的库和较大的 Vue 应用程序构建良好,但在服务时产生上述错误。

我开始认为我们的 Vue 依赖项之一的版本更改导致了问题。这是我们的 package.json 文件:

图书馆

"devDependencies": {
    "apollo-boost": "^0.4.4",
    "autoprefixer": "^9.6.1",
    "graphql": "^14.2.1",
    "material-design-icons-iconfont": "^5.0.1",
    "moment": "^2.24.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "vue": "^2.6.11",
    "vue-apollo": "^3.0.0-beta.28",
    "vuetify": …
Run Code Online (Sandbox Code Playgroud)

webpack vue.js vuejs2

5
推荐指数
1
解决办法
2024
查看次数

查询索引 IDB 上的对象

看起来应该很简单,但我不知道如何根据某个索引查询对象存储。

按数据库创建如下:

dbPromise = idb.open(idb_name, idb_version, db => {
  const reviewStore = db.createObjectStore('reviews', {
    keyPath: 'id'
  });
  reviewStore.createIndex('restaurant_id', 'restaurant_id', {unique: false});
});
Run Code Online (Sandbox Code Playgroud)

我已经创建了reviews带有索引的对象存储restaurant_id

存储的数据如下所示:

{
  comment: "Mission Chinese Food has grown...",
  createdAt: 1504095567183,
  id: 1123
  restaurant_id: 1
}
Run Code Online (Sandbox Code Playgroud)

但是,当我get这样拨打电话时:

db.transaction('reviews').objectStore('reviews').get('1')...
Run Code Online (Sandbox Code Playgroud)

id我得到的是 1 或什么都不是的对象,而不是restaurant_id.

如何检索与指定索引值匹配的对象数组?

node.js indexeddb

1
推荐指数
1
解决办法
1124
查看次数