我在进行以下测试时遇到此错误:
it('should call pauseAnimationInterval if in focus', inject(function(SearchBoxData, intervalManager, $timeout){
SearchBoxData.init_array = [];
SearchBoxData.inFocus = true;
SearchBoxData.init(intervalManager);
console.log(intervalManager.pauseTimeout);
console.log(intervalManager.pauseTimeoutTime);
console.log($timeout);
$timeout.flush(intervalManager.pauseTimeoutTime+1);
expect(rootScope.$broadcast).toHaveBeenCalledWith('onPauseInterval', intervalManager.loopIndex);
}));
Run Code Online (Sandbox Code Playgroud)
它打破$timeout.flush(intervalManager.pauseTimeoutTime+1);
$ timeout方法在intervalManager.pauseAnimationInterval()里面调用SearchBoxData.init(intervalManager):
intervalManager.pauseAnimationInterval = function (){
intervalManager.safeCancel(intervalManager.continueInterval);
intervalManager.safeCancel(intervalManager.initInterval);
intervalManager.initInterval = null;
intervalManager.continueInterval = null;
intervalManager.pauseTimeout = $timeout(function () {
if(intervalManager.inFocus === true){
intervalManager.loopIndex += 1;
if(intervalManager.loopIndex >= intervalManager.maxLoopIndex){
intervalManager.loopIndex = 0;
}
$rootScope.$broadcast("onPauseInterval", intervalManager.loopIndex);
intervalManager.continueAnimationInterval();
}else{
// Important condition: retry after the timeout if no focus
// main reason of …Run Code Online (Sandbox Code Playgroud) 我的主要问题是错误没有指向我的代码中的任何地方$apply,我们的项目中没有那么多调用.似乎产生错误的代码:
<input type="text"
placeholder="{{ $root.pg.t('HEADER.CITY_OR_POSTAL') }}"
data-ng-focus="decideToStop();" data-ng-blur="decideToStart()"
data-ng-model="search.selected"
typeahead-on-select="search.locationQuery(geo_locations, search.selected)"
typeahead="location.name for location in getLocations($viewValue) | filter: $viewValue | limitTo:8" class="semi-bold">
Run Code Online (Sandbox Code Playgroud)
在控制器中:
$scope.decideToStop = function(){
if($scope.actionTimeout){
$timeout.cancel($scope.actionTimeout);
$scope.actionTimeout = {};
}
$scope.MyService.CustomMethodThatDoesALotOfThings();
};
$scope.decideToStart = function(){
if(CustomCondition()){
$scope.actionTimeout = $timeout(function(){
$scope.MyService.AnotherCustomMethodThatDoesALotOfThings();
}, 150);
}
};
Run Code Online (Sandbox Code Playgroud)
$root.pg只是放在rootScopefor for中的服务中的polyglot.js库.search是与位置搜索相对应的服务.
我在输入字段中更改城市时收到错误.我不知道如何调试这个......
我有以下任务来构建我的应用程序:
const app = new Metalsmith(config.styleguide.path.root);
app.use(
msDefine({
production: false,
rootPath: '/'
})
);
app.use(
msIf(
gutil.env.config === 'release',
msDefine({
production: true,
rootPath: '/styleguide/'
})
)
);
app.build(...);
Run Code Online (Sandbox Code Playgroud)
我需要访问rootPath应用程序中的from,例如:
import stuff from 'stuff';
export class IconCtrl ...
...
_getIconPath(name: string, size: string): string {
switch (this.version) {
case 'current':
return `${stuff.rootPath()}/current/icn-${name}-${size}.svg`;
default:
return `${stuff.rootPath()}/legacy/${name}.svg`;
}
}
...
Run Code Online (Sandbox Code Playgroud)
到目前为止,我还没有找到一个干净的方法.我不确定如何在应用程序内构建时访问应用程序配置.
我在IE 9和10中制作.draggable工作时遇到了麻烦.使用的主要javascript包是:jquery-ui-1.9.1.min.js和jquery-1.8.2.min.js
代码基本上如下所示:
creation.texts.resize = function(){
jQuery('.modification-text.active .creation-resize-handler').draggable({
start: function(event, ui){
... some code ...
},
drag: function(event, ui){
... lots of code ...
},
stop: function(event, ui){
... some code ...
creation.texts.resize();
}
});
}
Run Code Online (Sandbox Code Playgroud)
它与chrome firefox等完美搭配.有没有人遇到过类似的问题?
更新:我刚刚在jsfiddle.net上尝试了一个小样本代码,工作正常.代码非常庞大,必须是其他一些问题.
更新2:可拖动元素似乎不可点击:我在同一页面上做了一些单独的测试,我可以使用.draggable就好了.我为故障元素添加了一个onclick警报,它没有在IE中触发.以下是该区域中元素的示例html代码:
<div id="modification-limit" style="left: 25px; top: 34.5px; width: 290px; height: 290px;">
<div class="modification-text text-active active first-text ui-draggable" id="text_1" style="left: 97px; top: 24px; z-index: 0; border: 1px dashed rgb(204, 204, 204);">
<img src="/images/creation/rotate.png" class="creation-rotate" style="display: block;">
<div class="creation-rotate-handler ui-draggable" style="display: …Run Code Online (Sandbox Code Playgroud) jquery resize internet-explorer-9 jquery-ui-draggable internet-explorer-10
angularjs ×3
gulp ×1
javascript ×1
jquery ×1
metalsmith ×1
resize ×1
settimeout ×1
typescript ×1